ALERT: Some images may not load properly within the Knowledge Base Article. If you see a broken image, please right-click and select 'Open image in a new tab'. We apologize for this inconvenience.

Use of 'seq' Linux command


Article ID: 168140


Updated On:




Most Linux systems have the 'seq' command - little known but very useful.N/A


Most Linux systems have the 'seq' command on them. It's a surprisingly little known and hence underused command!

What does it do? It prints out a sequence of numbers. For example:
[[email protected] dev]# seq 0 5

Which doesn't look overly useful or exciting!

Yet when troubleshooting it can be put to all manner of good use. Here's one that can be immensely useful in a networking environment: exploring a network.

You aren't sure what addresses are out there... A broadcast ping is one possibility, but often falls short:
  • Broadcast domain too large to dare use it.
  • Multiple dupe results to decode.
  • And many devices simply won't respond to it.
So instead we can use a simple combination of seq and ping to explore. 

I want to test a subset of addresses on the 192.168.128.x network. I want a single ping to each - nothing too aggressive or fast.
for ip in `seq -w 1 10`; do ping -c 1 192.168.128.$ip; done

This will ping each address thru just the once, sequentially. Obviously the ping itself can be customers as required in terms fo size, timeout etc.

This is just one example of the use of 'seq'. The example itself is useful in its own right - and hopefully iuulstrates the 'seq' command and hence how it might be used in many other ways.