From the course: Linux Bash Shells and Scripts: Streamlining Tasks and Enhancing Workflows with Automation

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Looping with for, the seq command, and backticks

Looping with for, the seq command, and backticks

- [Instructor] Let's look at some more advanced and, as it turns out, more useful techniques that you might want to use with loops. For example, the seq command, S-E-Q, will generate a sequence of numeric values. You say seq 1 5, it's going to echo out 1, 2, 3, 4, 5, so you can start out at a different number and with a different number and so forth. You can use that in a for loop, but in a for loop, you got to get the output of the seq command onto the command line. You can't pipe it into a for loop. If you pipe into a for loop, that doesn't make sense. You could pipe into a while loop, but then you have to use the read command. When you have a way to generate the list of things you want to iterate over in a for loop, then you put the command to generate the list in backticks. Those are not apostrophes; those are backwards-leaning ticks. Those are sometimes up underneath the Escape key way over on the left. Maybe it's with the little wavy bar, the tilde. It's not a quote, so if I do…

Contents