Bash Brace Expansion

March 24, 2011 Pivotal Labs

In our static assets directory, we have the following directories:

   public/images
   public/javascripts
   public/stylesheets

We want to namespace our application (my_app). We could type the following:

   mkdir public/images/my_app
   mkdir public/javascripts/my_app
   mkdir public/stylesheets/my_app

Or to save time, we could type:

   mkdir public/{images,javascripts,stylesheets}/my_app

This will create the three directories with one command.

For more information on bash curly brace expansion, checkout this article by Mitch Frazier on Linux Journal.

Another expansion I’ve used:

   cp file.txt{,.bak}
      cp file.txt file.txt.bak

About the Author

Biography

More Content by Pivotal Labs
Previous
Dropbox + git = Designer Luv
Dropbox + git = Designer Luv

One of the thornier problems in our workflow is knowing when assets are delivered from the designer and kee...

Next
New in Tracker: Story assignment notification, API additions
New in Tracker: Story assignment notification, API additions

We've added a new email notification to Pivotal Tracker which will let you know when someone assigns a stor...