One of the most common inefficient habits of Unix users is iterative directory creation:
$ mkdir project $ cd project $ mkdir docs $ cd docs $ mkdir html
You may (or may not) already be aware of the -p flag, which allows you to create parent AND child directories in one command:
$ mkdir -p project/docs/html
Not many people are aware, however, that you can create arbitrarily complex directory trees using the -p flag and some curly braces:
$ mkdir -p proj/{bin,etc,docs/{html,txt,pdf},src}
If the example above represented a common project layout, you could add a quick alias to .bashrc in your home directory:
alias mkproj="mkdir -p proj/{bin,etc,docs/{html,txt,pdf},src}"
Avi Flax said:
Wow, great tip – thanks!!