Bash seq command example and why we need it?

bash
seq

#1

So, I read some bash page and it said if you need a sequence of number use seq. I mean every page just says run:

seq 1 5

and it prints:

1
2
3
4
5

How does this help in my script? I mean I need some practical examples. Can you help?


#2

Say you have hostname like server01, server02, server03, server04, and server05. You need to log in to each box and get uptime or Linux kernel version. So you would run

ssh user@server1 uptime
ssh user@server1 uname -r

Now you can put it in bash for loop:

for i in $(seq 1 5)
do
     ssh user@server0${i} "uname -r"
done

Bash shell has inbuilt range too (no need to use seq):

for i in {1..5}
do
     ssh user@server0${i} "uname -r"
done