Created
April 23, 2013 18:56
-
-
Save gmale/5446371 to your computer and use it in GitHub Desktop.
For Each Folder. For each folder, run a given shell command. I use this to switch some (but not all) submodules to a particular branch. As in: bash$ fef ag-api ag-bizniz ag-data ag-data-commons Folders: ag-api ag-bizniz ag-data ag-data-commons
Enter the command you'd like to run in each of these folders: git checkout feature/SID-578-add-timely-s…
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 | |
folders=$@ | |
echo -e "\nFolders: $folders" | |
read -p "Enter the command you'd like to run in each of these folders: " commands | |
echo | |
for f in $folders | |
do | |
echo -e "\nEntering $f..." | |
cd $f 2> /dev/null | |
[[ $? -eq 0 ]] || { echo -e "\tFailed to find directory $f"; continue; } | |
bash -c "$commands" | |
cd - &> /dev/null | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment