Last active
August 20, 2018 22:34
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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