How to list a range of IP addresses with the Linux seq command

Ever needed to convert IP addresses that someone has written down into a list?
eg: to 52 and to 12

Try seq, as follows:

$seq -f "10.0.0.%g" 3 6

Or for my example:

$seq -f "10.0.0.%g" 47 52 ; seq -f "192.168.243.%g" 5 12

You could then redirect the output too:

$seq -f "10.0.0.%g" 47 52 ; seq -f "192.168.243.%g" 5 12 > ips.txt

Hope this is useful.


Leave a Reply

Your email address will not be published. Required fields are marked *