Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Beginners > Re: Best way to...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 11 Topic 10922 of 12261
Post > Topic >>

Re: Best way to grab lines n thru x of a file

by krahnj@[EMAIL PROTECTED] (John W. Krahn) Apr 10, 2008 at 10:36 AM

Chas. Owens wrote:
> On Thu, Apr 10, 2008 at 12:24 PM, Jonathan Mast
> <jhmast.developer@[EMAIL PROTECTED]
> wrote:
>> Hi, I have a ~125MB file of which I want to read lines n thru n+x and
write
>>  those into a separate file.  What is the best way to go about this?
> 
> Use the flip-flop operator* (..):
> 
> perl -ne 'print if $. == 20 .. $. == 50' file

Which could be written simply as:

perl -ne 'print if 20 .. 50' file


John
-- 
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall
 




 11 Posts in Topic:
Best way to grab lines n thru x of a file
jhmast.developer@[EMAIL P  2008-04-10 12:24:35 
Re: Best way to grab lines n thru x of a file
chas.owens@[EMAIL PROTECT  2008-04-10 12:54:06 
Re: Best way to grab lines n thru x of a file
krahnj@[EMAIL PROTECTED]   2008-04-10 10:36:28 
Re: Best way to grab lines n thru x of a file
jialinli1981@[EMAIL PROTE  2008-04-10 12:19:31 
Re: Best way to grab lines n thru x of a file
krahnj@[EMAIL PROTECTED]   2008-04-10 10:34:09 
Re: Best way to grab lines n thru x of a file
jhmast.developer@[EMAIL P  2008-04-10 16:35:14 
Re: Best way to grab lines n thru x of a file
Jim Gibson <jimsgibson  2008-04-10 17:27:45 
Re: Best way to grab lines n thru x of a file
Peter@[EMAIL PROTECTED]   2008-04-11 04:46:17 
Re: Best way to grab lines n thru x of a file
merlyn@[EMAIL PROTECTED]   2008-04-11 10:34:52 
Re: Best way to grab lines n thru x of a file
yitzle@[EMAIL PROTECTED]   2008-04-10 16:22:31 
Re: Best way to grab lines n thru x of a file
yitzle@[EMAIL PROTECTED]   2008-04-10 17:48:31 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Dec 3 17:46:45 CST 2008.