To copy/move/rename files with suffixes quickly:
cp /home/foo/abc.cpp{,-old}
equivalent to cp /home/foo/abc.cpp /home/foo/abc.cpp-old cp /home/foo/abc.cpp{,-old}
equivalent to cp /home/foo/abc.cpp /home/foo/abc.cpp-old foo/bar/{a,b,c}
expands out to foo/bar/a foo/bar/b foo/bar/c
and you can also use {1..9} to expand to all the numbers between 1 and 9 (inclusive).Here are some ways I commonly use it:
- Create lots of subdirectories at once:
mkdir -p test/{a,b,c}/{1..4}
- Rename/copy files (as in parent comment)- Removing lots of randomly named files, with common elements:
rm {a,d,f,gr}*
(this will remove all files starting with those prefixes...note that it will not delete other files starting with 'g', only those with 'gr')