Get in touch

Send an email to: lammers@gmail.com.
Or find me online at: Github, X

Brace expansion in bash

Brace expansion is a feature in the Bash that enables the generation of strings by defining patterns within curly braces {}. This can be useful when performing repetitive tasks or manipulating multiple files.

Some example uses are:

# Create a backup copy of a file and change the extension to `bak`
cp /path/to/some/file.{txt,bak}

# Create 5 new files with a single command
touch filename{1..5}.txt

# Replace the dash in the filename with an underscore
mv filename{-,_}01.txt