In the bash shell curly braces { and } are surprisingly useful things to reduce typing.
With the mkdir
command they help you create trees of directories in one command. For instance:
mkdir -p foo/{bar,baz,goo/loo/imp}/build |
will create the following directory structure:
foo/bar/build foo/baz/build foo/goo/loo/imp/build |
The curly braces can also be used with other commands such as cp
and mv
. E.g. you want to move file foo/bar/a.out to foo/bar/hello you can use the following command:
mv foo/bar/{a.out,hello} |
The source file (a.out) is separated from the destination file (hello) within the curly braces by the comma (,).
The curly braces are used in much the same way with cp
. For example if you want to copy foo/bar/hello to foo/baz/goodbye you would use the following command:
cp foo/{bar/hello,baz/goodbye} |