From the course: Linux Tips

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Bash expansions and substitutions

Bash expansions and substitutions - Linux Tutorial

From the course: Linux Tips

Bash expansions and substitutions

- [Instructor] In Bash, an expansion is a sequence of characters that represents or expands into something else. One useful expansion is called Brace expansion, and it allows us to specify a range of things that Bash then fills in. So if we need to create a series of files really quickly, we could write something like this. Using the touch command, I'll write touch file_ and then inside of curly braces, I'll write 1..100 and then a closing curly brace. These dots specify a range and when they're inside curly brackets, it tells Bash to expand one dot dot 100 into the sequence one, two, three, four, well you get the idea. I'll finish this off with .txt and I'll press enter. And now we have 100 files just like that. We can reverse the range too and have the expansion count down instead of up. This time I'll write echo file_ 100..1 inside curly braces and there we can see it's counted from 100 all the way down to one. We can set an increment by adding another set of dots. I'll write echo…

Contents