Skip to content

Instantly share code, notes, and snippets.

@munzz11
Last active August 1, 2022 23:31
Show Gist options
  • Select an option

  • Save munzz11/c684e1176aa1f6c3ec6eb1a5556ad63e to your computer and use it in GitHub Desktop.

Select an option

Save munzz11/c684e1176aa1f6c3ec6eb1a5556ad63e to your computer and use it in GitHub Desktop.
Recursive command execution through a directory
function recursive_for_loop {
for f in *; do
if [ -d $f -a ! -h $f ];
then
cd -- "$f";
echo "Executing in:`pwd`/$f";
#COMMAND GO HERE
# use recursion to navigate the entire tree
recursive_for_loop;
cd ..;
fi;
done;
};
recursive_for_loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment