in reply to Re: how to search for a string in a particular file?
in thread how to search for a string in a particular file?
#!/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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: how to search for a string in a particular file?
by roboticus (Chancellor) on May 29, 2012 at 10:59 UTC | |
by tm86 (Initiate) on May 29, 2012 at 13:35 UTC | |
by roboticus (Chancellor) on May 29, 2012 at 18:56 UTC | |
by tm86 (Initiate) on May 30, 2012 at 04:31 UTC | |
|
Re^3: how to search for a string in a particular file?
by ww (Archbishop) on May 29, 2012 at 10:33 UTC | |
|
Re^3: how to search for a string in a particular file?
by vinian (Beadle) on May 29, 2012 at 14:20 UTC | |
|
Re^3: how to search for a string in a particular file?
by Anonymous Monk on Jul 30, 2019 at 07:08 UTC | |
by haukex (Archbishop) on Jul 30, 2019 at 07:22 UTC |