ZWcarp has asked for the wisdom of the Perl Monks concerning the following question:
I am wondering how to write the awk one liner :
cat <filename> | awk '$2 ~ /GRHL3/{print NR"\t"$0}'
which prints out the( or any) line that has the string "GRHL3" in it as well as its respective line number
the perl one liner for the same task I have so far is perl -ne 'print if /GRHL3/' <filename>
What do I have to add so that it will also print out the line number ... I feel like $. has to go somewhere? Thanks so much!! Also does someone know of a good web resource where you can look this sort of thing up (specifically about one liners).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: print if // line number?
by ikegami (Patriarch) on Jun 07, 2011 at 23:08 UTC | |
by ZWcarp (Beadle) on Jun 08, 2011 at 00:52 UTC | |
|
Re: print if // line number?
by kennethk (Abbot) on Jun 07, 2011 at 22:43 UTC | |
|
Re: print if // line number?
by toolic (Bishop) on Jun 07, 2011 at 22:46 UTC | |
by planetscape (Chancellor) on Jun 08, 2011 at 00:07 UTC |