Thursday, June 30, 2011

run same command on multiple directories


I've been working on applications that consist of multiple maven projects.
Many time, I have to type same commands on multiple project directories, such as "mvn install", "svn up", "git …", etc.


I wrote a bash script that executes given command(s) on multiple directories.

Multiple Directory Command:


Sample: (mc is the script alias I use)

  > mc svn up                            # svn up all projects
  > mc -g projA mvn install     # call "mvn install" on porjA group directories(defined in config file)
  > mc git checkout -b new_branch master  # create a new git branch to all project

  > mc git branch                      # display current git branch in all project
  > mc -g projA svn up             #  "svn up" projA directories
  > mc -g projB -c config_file du -sh  # chcek directory size of projB directories

please see more options here.