Friday, March 04, 2011

Multi line matching in Perl ...

From this web page: http://perldoc.perl.org/perlfaq6.html#How-can-I-pull-out-lines-between-two-patterns-that-are-themselves-on-different-lines?

Here's what I did ...
#!/bin/sh

for i in `perl -ne 'print if /<blocks>/ .. /<\/blocks>/' our_config.xml | sed -e "s/<blocks>//g" | sed -e "s/<\/blocks>//g"`
do
        IPADDRS="$IPADDRS $i"
done
IPADDRS=`echo $IPADDRS | sort -u`
for i in $IPADDRS
do
        echo "`host $i | awk '{print $5}'` $i"
done

No comments:

Post a Comment