Click to See Complete Forum and Search --> : Help with GREP command needed


kimskams80
12-12-2009, 07:11 PM
Here there is another problem that I hope i can get solved here:

Can we use grep command to FIND a particular Pattern in a file AFTER a particular line number??

Let say I have line=445 and I want to find pattern "<HTML>" after this line number in file "File.txt" and also

Can we use GREP command to determine the TOTAL number of Lines in a file ???

Thanks in Advance

Sixtease
12-13-2009, 07:48 AM
open my $file, '</path/to/file' or die "Couldn't open: $!";
while (<$file>) {
next if $. < 445; # ignore lines up to 445
print "Line no $.: $_" if /<html/i;
}

kimskams80
12-14-2009, 08:22 AM
Thanks :)