I\'m trying to use an array to store a list of file names using the find
command.
For some reason the array fails to work in the bash used by the school
I think starpause has the cleanest solution, however it fails when there is whitespaces in paths. This is fixed by setting IFS
. The correct answer is therefore:
IFS=$'\n'
for i in $(find . -name '*.mov' );
do
echo "$i"
done
unset IFS
You unset IFS in order to reset behaviour for IFS and as to why the $
is needed in IFS=$'\n'
, see https://unix.stackexchange.com/questions/184863/what-is-the-meaning-of-ifs-n-in-bash-scripting