0

I'm trying to loop through each files from current directory and subdirectories. But the problem is file names with blank-space are getting treated as separate files. How do I prevent that. I want to use for loop, here is my current code.

for file in $(find . -type f -print)
do
    echo "$file";
done;
  • [This question](https://unix.stackexchange.com/questions/321697/why-is-looping-over-finds-output-bad-practice) doesn't answer my question. –  Feb 14 '21 at 16:19
  • 1
    The best you can do with the for-find construct is to set IFS to newline \n and disable globbing. Then if no filenames contain a newline you can use this method. – guest_7 Feb 14 '21 at 17:13

0 Answers0