Using braces in bash

Another great bash tip from Deadman.org | Advancing in the Bash shell:

Everyone has done one of the following to make a quick backup of a file:

$ cp filename filename-old
$ cp filename-old filename

These seem fairly straightforward, what could possibly make them more efficient? Let’s look at an example:

$ cp filename{,-old}
$ cp filename{-old,}
$ cp filename{-v1,-v2} 

Leave a Reply

Your email address will not be published. Required fields are marked *