Skip to content

Instantly share code, notes, and snippets.

@lxhunter
Last active September 7, 2018 15:31
Show Gist options
  • Save lxhunter/16d0074385332575484e3a9678af9d28 to your computer and use it in GitHub Desktop.
Save lxhunter/16d0074385332575484e3a9678af9d28 to your computer and use it in GitHub Desktop.
Executing command in all direct sub directories
#!/bin/bash
for directory in *; do
if [ -d "${directory}" ]; then
echo "${directory}:"
(
cd "${directory}"
exec "${@}"
)
fi
done
exit 0
@lxhunter
Copy link
Author

lxhunter commented Jan 5, 2017

Can be used like so:

multi_dir_exec ln -s ~/.bin/commit-msg.sh .git/hooks/commit-msg

It takes the command as arguments

BE CAREFUL!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment