When do you use brace expansion?

Benjamin

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.

dogbane

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

how to use variables with brace expansion

From Java

How do you avoid the extra carriage return when you use Zsh history expansion?

From Dev

Can I use a variable in a Bash brace expansion?

From Dev

In bash, is it possible to use an integer variable in a brace expansion

From Dev

Can I use bash brace expansion in for loop?

From Dev

How can I do brace expansion on variables?

From Dev

Use php exec to launch a linux command with brace expansion

From Dev

How can I use $variable in a shell brace expansion of a sequence?

From Dev

Expanding a brace expansion string held in a variable for use in a for loop?

From Dev

Use php exec to launch a linux command with brace expansion

From Dev

How do I copy files with curly brace expansion in the path?

From Dev

How do I get 0-padded numbers in {} (brace expansion)?

From Dev

How to create file names containing spaces when using brace expansion?

From Dev

brace expansion command not recognized

From Dev

Brace expansion with numbers in bash

From Dev

Brace expansion in python glob

From Dev

Brace expansion with $@ arguments

From Dev

Brace expansion with variable?

From Dev

Using brace expansion in if statement

From Dev

BASH brace expansion algorithm

From Dev

Why is brace expansion not supported?

From Dev

Brace expansion with numbers in bash

From Dev

shell - brace expansion not working

From Dev

Bash Brace Expansion & Variables

From Dev

Comparison and brace expansion

From Dev

Brace expansion not working in a script

From Dev

Expand variable in brace expansion

From Dev

Brace expansion does not work

From Dev

rsync brace expansion insight