Last active
January 14, 2021 12:29
-
-
Save yatishbalaji/f8454d9cef45e7fc7e7b2d2703ef764f to your computer and use it in GitHub Desktop.
Create Alias to run any command on multiple directories. EG: Used for maintaining multiple git repositories by single command
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
| export workspace=($HOME"/projects/project1" $HOME"/projects/project2"); | |
| export multiDirExec() { | |
| for dir in ${workspace[@]}; do | |
| echo 'Running >>>> '$dir ' >>>> ' $1 ; | |
| (cd "$dir" && eval "$1"); | |
| done; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use case
Usage
for dir in ~/projects/*;Examples
multiDirExec "git remote update origin"multiDirExec "git pull origin feat/gitlessons --rebase"multiDirExec "grupo"