On Fri, 2007-10-19 at 01:55 +0200, Dr.Ruud wrote: > yitzle schreef: > > > If you are on a Linux machine, it might just be easier > > to use the grep command with a shell script. > > > > FILE_NAME="./log" > > TMP_FILE="./tmp" > > IP_TO_REMOVE="192.168.0.0|192.168.0.255" > > > > COUNT=`grep $IP_TO_REMOVE $FILE_NAME | wc -l` > > echo "The IPs occur $COUNT times" > > > > grep -v $IP_TO_REMOVE $FILE_NAME > $TMP_FILE > > mv $TMP_FILE $FILE_NAME > > Be careful, the 192.168.0.0 can also match a line with 192.168.010 in > it. See also the -F option of grep. > > -- > Affijn, Ruud > > "Gewoon is een tijger." >
Good point, bad example (although natural continuation of previous discussion). Most programs won't output leading 0's in IP addresses (and then it likely wouldn't match any since it would be 192.168.000.000), but there are many other possibilities of any number along the lines of [1-25]\d. Including a following delimiter of some kind would be another option to qualify. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/