Use seq to add range of numers in a loop

In bash use the seq command to add a range of numbers in a loop.

for i in `seq 10 20`; do telnet $i;done

Note back ticks around the seq command and arguments. The bash v2 option of using the $() can be used here.

This particular example could be used as a simple port scanner.

Back to GNU/Linux Command Line Tips