use awk to find missing element of sequential list

Start with a list of a /24 of IP addresses:

# tail list.txt
        10.1.59.248
        10.1.59.249
        10.1.59.251
        10.1.59.252
        10.1.59.254

Find the missing elements from the sequence of last octets:

# awk -F [./] 'BEGIN{i=0}{i++;if(i!=$4){print i;i=$4}}' list.txt
250
253
share:

Leave a Reply

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