Create and Copy Multiple Files with Brace Expansions in Bash

Cameron Nokes
InstructorCameron Nokes

Share this video with your friends

Send Tweet

Brace expansions are commonly used with the cp or mv commands in order to dynamically generate strings. In this lesson, we'll use a brace expansion to shorten a command like cp index.js index.js.backup to cp index.js{,.backup}. We'll also see how brace expansions can generate sequences. For example, touch test-{1..10} will generate the arguments to touch to create 10 test files.

Note that the tree command that I use in this lesson has to be installed.