We're an ISO27001:2013 Certified Supplier


Here’s how to make a backup copy of a file:

$ cp MyLongFileName MyLongFileName.bak

Here’s a quicker way of achieving the same thing:

$ cp MyLongFileName{,.bak}

How it works

The shell expands the comma-separated list within the braces, appending each value in turn to the file name. The first character within the braces is a comma, so the first comma-separated string is null; the second is .bak. That means that the second command above expands to be exactly the same as the first.

Want to make a copy of all *.conf files in a directory?

$ for a in *.conf;do cp $a{,.bak};done

What’s your favourite Linux tip?

Let us know in the comments below.

Secure. Reliable. Scalable.

If that doesn't describe your current Linux systems, check out our FREE Linux Survival Guide to help you get your systems up to scratch today!
  • This field is for validation purposes and should be left unchanged.