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.
|
I understand what brace expansion is, but I don't know how best to use it. When do you use it? |
||||
|
|
|
Brace expansion is very useful if you have long path names. I use it as a quick way to backup a file:
will copy You can also use it in a sequence. I once did so to download lots of pages from the web:
or
|
|||||||||
|
|
Brace expansion comes very handy when creating large directory structures:
This will give you
You could even go one step further and put brace expansion into brace expansion:
This will give you the same directory structure as the example above. |
|||||||||||||||
|
|
I use it when I want to reduce typing:
Another example:
|
|||||
|
|
I use it to compare actual test output to desired test output during development. If test #41 fails, it's easy to see what the difference between the test output (in file tests.output/041) and the desired output (in file tests.out/041):
|
||||
|
|
|
Some frequent cases for me are: For renaming:
or
or
(Although it's less messy to use version control for the last 2 tasks.) For comparing (already mentioned):
|
||||
|
|