2 ms·
Braces in general are great for all sorts of tasks. The general principle is that it duplicates arguments, with changes. Thus, foo/bar/{a,b,c} expands out t
by apu 17y ago
Braces in general are great for all sorts of tasks. The general principle is that it duplicates arguments, with changes. Thus,
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')