Tutorial by Examples

$ mkdir 20{09..11}-{01..12} Entering the ls command will show that the following directories were created: 2009-01 2009-04 2009-07 2009-10 2010-01 2010-04 2010-07 2010-10 2011-01 2011-04 2011-07 2011-10 2009-02 2009-05 2009-08 2009-11 2010-02 2010-05 2010-08 2010-11 2011-02 2011-05 2011-08 2011...
$ cp .vimrc{,.bak} This expands into the command cp .vimrc .vimrc.bak.
$ mv filename.{jar,zip} This expands into mv filename.jar filename.zip .
$ echo {0..10..2} 0 2 4 6 8 10 A third parameter to specify an increment, i.e. {start..end..increment} Using increments is not constrained to just numbers $ for c in {a..z..5}; do echo -n $c; done afkpuz
Bash can easily create lists from alphanumeric characters. # list from a to z $ echo {a..z} a b c d e f g h i j k l m n o p q r s t u v w x y z # reverse from z to a $ echo {z..a} z y x w v u t s r q p o n m l k j i h g f e d c b a # digits $ echo {1..20} 1 2 3 4 5 6 7 8 9 10 11...
mkdir -p toplevel/sublevel_{01..09}/{child1,child2,child3} This will create a top level folder called toplevel, nine folders inside of toplevel named sublevel_01, sublevel_02, etc. Then inside of those sublevels: child1, child2, child3 folders, giving you: toplevel/sublevel_01/child1 toplevel/s...

Page 1 of 1