I have a log file which is more than 1GB, i need to take count from the log file for two strings. i am using the below command but it take a long time to excetue, i need to tune this. Please help me
The point with the sed is that it takes more time than a single grep, but you can replace all the greps with a single sed script.
Unless you are a skilled C programmer, I doubt that you can make this a lot faster by switching languages. C programs are compiled, you don't need the C compiler on the box itself in order to run the resulting binary.
You can use Perl. It will give you better results than grep i think.
Here are few tips for searching ...
do not store the file contents in an array, if the file size is huge
loop thru using the file handle ex: while (my $line = <FILE>) {
to make things faster, use variables as counters. If you want to match say 5 times ... you need not have to parse the entire file in loop, exit after 5 matches using a counter var.
Regards,
Visit my Perl blog for tips on Perl, TechDiary