I understand what brace expansion is, but I don't know how best to use it.
When do you use it?
Please teach me some convenient and remarkable examples if you have your own tip.
Brace expansion is very useful if you have long path names. I use it as a quick way to backup a file:
cp /a/really/long/path/to/some/file.txt{,.bak}
will copy /a/really/long/path/to/some/file.txt
to /a/really/long/path/to/some/file.txt.bak
You can also use it in a sequence. I once did so to download lots of pages from the web:
wget http://domain.com/book/page{1..5}.html
or
for i in {1..100}
do
#do something 100 times
done
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments