#!/usr/bin/perl -w use strict; while () { if (/\s(159\.230\.\d+\.\d+)/) { print $1,"\n"; } } __DATA__ network-object 159.230.123.000 255.255.224.0 network-object 159.230.234.000 255.255.252.0 network-object 159.230.111.000 255.255.255.0 network-object host 159.230.101.000 network-object host 159.230.200.000 network-object host 159.230.6.000