Created
September 4, 2014 14:11
-
-
Save mslinn/8248b0491bacf651fefd to your computer and use it in GitHub Desktop.
Executes a command on all subdirectories one level down from the current directory. Expects to find a subdirectory of git projects
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 | |
set -eo pipefail | |
HIGHLIGHT="\e[01;34m" | |
NORMAL='\e[00m' | |
if [ -z "$2" ]; then | |
echo "Usage: $(basename $0) dirPattern command" | |
echo " Where dirPattern can be an absolute or relative path. If wildcards are used, enclose the dirPattern in single quotes" | |
exit -1 | |
fi | |
DIRS=$(eval echo '$1') | |
shift | |
for f in $DIRS; do | |
if [ ! -f "$f/.ignore" ]; then | |
cd $f | |
printf "%b\n" "\n${HIGHLIGHT}$(basename $PWD)$d${NORMAL}" | |
$* | |
echo "" | |
cd - >/dev/null | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment