Skip to content

Instantly share code, notes, and snippets.

@unrelentingfox
Last active August 20, 2018 22:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unrelentingfox/0c136dc0cb3c70912f6cc91001e1e1f5 to your computer and use it in GitHub Desktop.
Save unrelentingfox/0c136dc0cb3c70912f6cc91001e1e1f5 to your computer and use it in GitHub Desktop.
Runs whatever bash commands you enter as parameters from each child directory. WARNING: this could be potentially distructive.. Use at your own risk.
#!/bin/bash
# Runs whatever bash commands you enter as parameters from each child directory.
CYAN=$'\e[0;36m'
RED=$'\e[31m'
NO_COLOR=$'\e[0m'
CLEAR=$'\e[K'
INVERTED=$'\e[7m'
UNINVERTED=$'\e[27m'
printf "Executing '$*' from all child directories of $PWD\n"
printf "${RED}WARNING: This could be potentially destructive. Continue at your own risk!${NO_COLOR}\n"
for d in */ ; do
cd "$d"
printf "${CYAN}$d\n"
printf "${INVERTED}Press ENTER to continue${NO_COLOR}${UNINVERTED}" #prompt message
read -p "" -s
printf "\r${CLEAR}" #clear the line to remove the prompt message
$*
wait
cd ..
done
printf "${CYAN}DONE!\n${NO_COLOR}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment