#!/usr/bin/perl # main program; print "Enter the filename to be parsed\n"; my $file = <STDIN>; open (FILE,$file); @lines = <FILE>; close (FILE); print "Enter the keyword to be searched in the file\n"; chop (my $key = <STDIN>); if (grep {$_ eq $key} @lines) # Search for the key pattern in +the file information. { print "$_ \n"; # If found print the line } else { print "Keyword not found\n"; }
In reply to Error using grep by justkar4u
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |