Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: extract (a range of) numbered lines from a file -- oneliner

by Discipulus (Canon)
on Sep 20, 2016 at 07:34 UTC ( [id://1172203]=note: print w/replies, xml ) Need Help??


in reply to extract (a range of) numbered lines from a file

sed -e '10,15p;4p;s/.*// file | awk !/^$/{print $0} somefile'

Sorry but I dont speak urdu.. but I would go with

# warning windows double quotes perl -nle "BEGIN{map{$w{$_}++}map{/^(.*\d)-(.+)$/?$1..$2:$_}split /,/, +pop @ARGV}print if exists $w{$.}" FILENAME 1,2,4-6,11-13

++ for your post

L*

PS: the regex is inspired from rosettacode

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-19 23:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found