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

2008-04-11 Thread Randal L. Schwartz
> ""Jonathan" == "Jonathan Mast" <[EMAIL PROTECTED]> writes: "Jonathan> The line numbers are 4million to 4million + some odd hundred thousand, just "Jonathan> to give an idea of the size. Sounds like you want a database, not a flat file. Time to migrate. -- Randal L. Schwartz - Stonehenge

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

2008-04-11 Thread Peter Scott
On Thu, 10 Apr 2008 16:35:14 -0400, Jonathan Mast wrote: > perl -ne 'print if 20 .. 50' file looks perfect but I totally don't > understand it perldoc perlop: In scalar context, ".." returns a boolean value. The operator is bistable, like a flip-flop, and emulates the line-rang

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

2008-04-10 Thread yitzle
On Thu, Apr 10, 2008 at 4:35 PM, Jonathan Mast <[EMAIL PROTECTED]> wrote: > Thanks for all the input. > > The head / tail solution would work, but isn't very scalable. I did > something similar on another file of comparable size and it took a long time > to complete. > > The line numbers are 4

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

2008-04-10 Thread Jonathan Mast
Thanks for all the input. The head / tail solution would work, but isn't very scalable. I did something similar on another file of comparable size and it took a long time to complete. The line numbers are 4million to 4million + some odd hundred thousand, just to give an idea of the size. The se

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

2008-04-10 Thread yitzle
or use sed! To print lines 5 through 10: sed -ne '5,10p' -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

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

2008-04-10 Thread John W. Krahn
Chas. Owens wrote: On Thu, Apr 10, 2008 at 12:24 PM, Jonathan Mast <[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 $

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

2008-04-10 Thread John W. Krahn
Jonathan Mast wrote: Hi, Hello, 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? while ( ) { # read and ignore up to n last if $. == $n - 1; } while ( ) { print; last if $. == $

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

2008-04-10 Thread Jialin Li
or use head and tail command head -n50 file | tail -n30 On Thu, Apr 10, 2008 at 11:54 AM, Chas. Owens <[EMAIL PROTECTED]> wrote: > On Thu, Apr 10, 2008 at 12:24 PM, Jonathan Mast > <[EMAIL PROTECTED]> wrote: > > Hi, I have a ~125MB file of which I want to read lines n thru n+x and > write > > t

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

2008-04-10 Thread Chas. Owens
On Thu, Apr 10, 2008 at 12:24 PM, Jonathan Mast <[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? > > thanks > Use the flip-flop operator* (..): perl -ne 'print if $. ==

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

2008-04-10 Thread Mathew
I think a simpler solution would be to use head and tail: head -n x > file.txt tail -n x-n file.txt > file2.txt Xavier Noria wrote: On Apr 10, 2008, at 18:24 , Jonathan Mast 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

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

2008-04-10 Thread Xavier Noria
On Apr 10, 2008, at 18:24 , Jonathan Mast 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? Tie::File -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PRO

Best way to grab lines n thru x of a file

2008-04-10 Thread Jonathan Mast
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? thanks