am encountering strange behavior when executing the following bash script:
#! /bash/bin
dirs=$(ls .)
for dir in $dirs ; do
files=$(ls $dir)
for file in $files ; do
line=$(head -n -1 $dir/$file)
echo $line
done
done
Instead of the echo of $line, I am getting the results of a ls / command, followed by the echo of $line, followed by the contents of $files. My guess is that I am exceeding some limit in bash: I have 171 directories, each with 500 files. When I add the line:
echo ${#line}
to the script, I get the right answer (68); but the echo of $line fills my terminal window. What can I do now?