[Bash] How to iterate over lines of standard output of command

[Bash] How to iterate over lines of standard output of command

It’s very easy to iterate over lines of standard output of command.

Here is an example:

#!/bin/sh
 
for i in `seq 0 5 15`
do
	echo $i
done

The output is:

0
5
10
15

seq 0 5 15 iterates from 0 to 15 with step 5

`command` executes command and return its standard output

One thought on “[Bash] How to iterate over lines of standard output of command

Leave a Reply

Your email address will not be published.