Bash Expansion

From Psygen Wiki
Revision as of 03:34, 15 July 2017 by Admin (talk | contribs) (Created page with "Bash brace expansion "autofills" some commands for you. == Create Multiple files == <code>touch file{1,2,3,4}.txt</code> - Expands to: <pre> file1.txt file2.txt file3.t...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Bash brace expansion "autofills" some commands for you.


Create Multiple files

touch file{1,2,3,4}.txt - Expands to:

 file1.txt
 file2.txt
 file3.txt
 file4.txt


So, we can use a comma to separate the stuff we want to expand. Can we do ranges, I don't want to type all that?

We sure can!!


touch file{1..6}.txt - Expands to:

 file1.txt
 file2.txt
 file3.txt
 file4.txt
 file5.txt
 file6.txt