Unix Power Tools
Build Strings with { }

I've been finding more and
more uses for the {} pattern-expansion characters in
csh, tcsh, and bash. They're
similar to *, ?, and [], but they
don't match
filenames the way that *, ?, and []
do. You can give them
arbitrary text (not just filenames) to expand. That "expand-anything"
ability is what makes them so useful.

Here are some examples to get you thinking:

To fix a typo in a filename (change fixbold5.c to
fixbold6.c):

% mv fixbold{5,6}.c

An easy way to see what the shell does with {} is by adding echo before the mv:

% echo mv fixbold{5,6}.c
mv fixbold5.c fixbold6.c

To copy filename to filename.bak in one easy step:

% cp filename{,.bak}

To print files from
other directory(s) without retyping the whole pathname: