> > > 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
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
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
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
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_
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
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#
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/
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
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
10 matches
Mail list logo