Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Answer: What is the simplest way to print a field, as in $3 does in awk

( #120753=categorized answer: print w/ replies, xml ) Need Help??

Q&A > strings > What is the simplest way to print a field, as in $3 does in awk contributed by jmcnamara

Use the -a switch to autosplit to @F.
perl -lane 'print if $F[1] =~ /localhost/' /etc/hosts
or     perl -lne 'print if /localhost/' /etc/hosts
--
John.

Comment on Answer: What is the simplest way to print a field, as in $3 does in awk
Select or Download Code
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2015-07-02 03:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (27 votes), past polls