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?
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?
if you want to perform an action INSIDE the folder and not ON folder.
Explanation: You have many pdfs and you would like to concetrate them inside a single folder. my folders
AV 001/
AV 002/
for D in *; do cd "$D"; # VERY
DANGEROUS COMMAND - DONT USE
#-- missing "", it will list files too. It can go up too.for d in */; do cd "$d"; echo $d; cd ..; done; # works
succesfullyfor D in "$(ls -d */)"; do cd "$D"; done; #
bash: cd: $'Athens Voice 001/\nAthens Voice 002/' - there is no such
folderfor D in "$(*/)"; do cd "$D"; done; # bash: Athens
Voice 001/: is folderfor D in "$(`find . -type d`)"; do cd $D; done; # bash: ./Athens: there is no such folder or filefor D in *; do if [ -d "${D}" ] then cd ${D}; done; # many
arguments