#!/tools/packarch/public/perl/5.8.8/bin/perl use strict; use warnings; open(my $file, "<", "input.txt") or die "Can't open input.txt: $!" +; my $string = "icecream"; while (<$file>) { if (/$string/) { print "found string $string\n"; } else { print "did not find the string\n"; } }
this is what i could come up with. it worked correctly... but i'd like to know more about using the grep command.
In reply to Re^2: how to search for a string in a particular file?
by tm86
in thread how to search for a string in a particular file?
by tm86
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |