I have this code and when I try it in FreeBSD it shows me a lot of errors... how can I fix it? I check directories, if it match with variable IGN. NAME_d should be an array.
max_d=$(find "${DIR}" -type d | wc -l)
for i in `seq 1 $max_d`
do
check_d=$(find "${DIR}" -type d | head -n "${i}" | tail -n -1 | tr '\/' '\n' | egrep -n "${IGN}")
if [ ! -z "$check_d" ]; then
NAME_d+=$i"d "
fi
done
directory_d=${NAME_d[*]}
sedCmds_d=${directory_d// /;}

seqloop with a previous find and another find in the loop reading only one line from each find. This is far from optimal. Rethink your work! How aboutlet x=0; find . -type d | while read dir; do let 'x++'; DO YOUR WORK WITH $dir HERE, POSSIBLY ALSO USING LINENO $x.; donebash, which has allowed+=for assignment statements since version 3.1. In addition,NAME_dis not an array even if you were usingbash.