I am working on a script that needs to perform an action in every sub-directory of a specific folder.
What is the most efficient way to write that?
This will create a subshell (which means that variable values will be lost when the while loop exits):
while
find . -type d | while read -r dir do something done
This won't:
while read -r dir do something done < <(find . -type d)
Either one will work if there are spaces in directory names.