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
WWF Earth Hour App Created By Xtreme Labs
WWF Earth Hour App Created By Xtreme Labs

Tell ghost stories? Look at the stars? Host an earth our party? Make street light puppets?… it is surprisi...

Next
Noop Handler – Catching 80K requests per second without breaking a sweat
Noop Handler – Catching 80K requests per second without breaking a sweat

Sure it's a noop test and running on a iMac i7, but 80K requests per second is pretty impressive for 40 lin...

Enter curious. Exit smarter.

Register Now