Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Break one liner command line script after first match

by McA (Priest)
on Oct 30, 2013 at 12:03 UTC ( #1060345=note: print w/ replies, xml ) Need Help??


in reply to Break one liner command line script after first match

Hi

why not just exiting after printing the matched line?

UPDATE: perl -ne'/(data)/ && print($1) && exit' file.txt

McA


Comment on Re: Break one liner command line script after first match
Download Code
Re^2: Break one liner command line script after first match
by hdb (Prior) on Oct 30, 2013 at 12:33 UTC

    Or die!

    perl -ne'/(data)/ && die $1' file.txt

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1060345]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (12)
As of 2015-07-06 16:39 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 (77 votes), past polls