While running the bash command
myarray="(`find -type d -printf '%d\t%P\n' | cut -f2`)"
on my present working directory, and then output the contents of myarray,
tLen=${#myarray[@]}
for (( i=0; i<${tLen}; i++ ))
do
echo "${myarray[$i]}"
done
directory names with white space get split. i.e. The white spaces in the directory name 'My tax documents' aren't automatically escaped and ends up becoming three entries in the array, 'My' 'tax' 'documents' rather then just one name. However running
find -type d -printf '%d\t%P\n' | cut -f2
from the command line works just fine. How do I prevent word splitting when assigning the output of find into an array?