Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Getting lines in a file between two patterns

by Utilitarian (Vicar)
on Jul 05, 2012 at 05:13 UTC ( #979950=note: print w/ replies, xml ) Need Help??


in reply to Getting lines in a file between two patterns

One option would be to use the range operator eg.

perl -e 'while (<>){print if (/^START/../^END/);}' input.txt
print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."


Comment on Re: Getting lines in a file between two patterns
Select or Download Code
Replies are listed 'Best First'.
Re^2: Getting lines in a file between two patterns
by frozenwithjoy (Curate) on Jul 05, 2012 at 05:21 UTC
    This will also print START/END, if this is not desired, try:
    perl -ne 'if (/START/../END/) {print unless /START/ or /END/}'

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2015-07-29 03:19 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 (260 votes), past polls