Last active
May 31, 2021 15:55
-
-
Save rojenzaman/371a6f4e980a0d68a8ca6c0fa49b9f3b to your computer and use it in GitHub Desktop.
Run specific command or script in all sub-directories.
This file contains 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 | |
cd "$(dirname "${BASH_SOURCE[0]}")" | |
function execute() { | |
cd $i | |
echo -e "\e[91m$x:\e[0m\e[92m`pwd`\e[0m" | |
case $1 in | |
ls) $@ --color=auto ;; | |
grep) $@ --color=auto ;; | |
fgrep) $@ --color=auto ;; | |
egrep) $@ --color=auto ;; | |
*) $@ ;; | |
esac | |
echo "" | |
} | |
x=0 | |
for i in */; do | |
x=$((x+1)) | |
( execute $@ ) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment