Re: Search for IP address and delete from file

2007-10-18 Thread Matthew Whipple
> > > 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 > discuss

Re: Search for IP address and delete from file

2007-10-18 Thread Matthew Whipple
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_R

Re: Search for IP address and delete from file

2007-10-18 Thread Dr.Ruud
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

Re: Search for IP address and delete from file

2007-10-17 Thread Phillip Gonzalez
FreeBSD, and that's actually what I ended up doing basically using cat and grep -v. Thanks, On Oct 17, 2007, at 9:14 PM, yitzle wrote: 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.16

Re: Search for IP address and delete from file

2007-10-17 Thread yitzle
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_

Re: Search for IP address and delete from file

2007-10-17 Thread Jeff Pang
On 10/18/07, Phillip Gonzalez <[EMAIL PROTECTED]> wrote: > Hi, > > I'm trying to search a .txt file for matching ip addresses. I then want to > delete those ip >addresses. > The better way for finding an IP from given list is to use Net::IP module from CPAN rather than using regex I think. -- T

Re: Search for IP address and delete from file

2007-10-17 Thread Phillip Gonzalez
They have all been helpful. Thanks, On Oct 17, 2007, at 4:40 PM, Matthew Whipple wrote: Matthew Whipple wrote: yitzle wrote: Take a look at the grep function http://perldoc.perl.org/functions/grep.html Also of potential use is the qr// quote operator: http://perldoc.perl.org/perlop.html#

Re: Search for IP address and delete from file

2007-10-17 Thread Matthew Whipple
Matthew Whipple wrote: > yitzle wrote: > >> Take a look at the grep function >> http://perldoc.perl.org/functions/grep.html >> >> Also of potential use is the qr// quote operator: >> http://perldoc.perl.org/perlop.html#Regexp-Quote-Like-Operators >> >> This lets you do: >> >> my $ip_search = qr/

Re: Search for IP address and delete from file

2007-10-17 Thread Matthew Whipple
yitzle wrote: > Take a look at the grep function > http://perldoc.perl.org/functions/grep.html > > Also of potential use is the qr// quote operator: > http://perldoc.perl.org/perlop.html#Regexp-Quote-Like-Operators > > This lets you do: > > my $ip_search = qr/$ip_string/; > my @lines_with_ip = grep

Re: Search for IP address and delete from file

2007-10-17 Thread yitzle
Take a look at the grep function http://perldoc.perl.org/functions/grep.html Also of potential use is the qr// quote operator: http://perldoc.perl.org/perlop.html#Regexp-Quote-Like-Operators This lets you do: my $ip_search = qr/$ip_string/; my @lines_with_ip = grep /$ip_search/, @raw_data; # or