From: superpollo on
hi.

i have a text file, and i just wanted to get, say lines 3 thru 7, or
just line 7. my first guess is:

cat | tail -n+3 | head -n+$((7-3+1))

but can it be made better?

bye
From: superpollo on
superpollo ha scritto:
> hi.
>
> i have a text file, and i just wanted to get, say lines 3 thru 7, or
> just line 7. my first guess is:
>
> cat | tail -n+3 | head -n+$((7-3+1))

or:

cat | tail -n+7 | head -n+1

>
> but can it be made better?
>
> bye
From: pk on
superpollo wrote:

> hi.
>
> i have a text file, and i just wanted to get, say lines 3 thru 7,

sed -n '3,7p'
sed '3,7!d'
awk 'NR==3,NR==7'

> or just line 7

sed -n '7p'
sed '7!d'
awk 'NR==7'

If the file is very large you may want to add some statement to exit right
after line 7.
From: Stachu 'Dozzie' K. on
On 2010-01-10, superpollo <utente(a)esempio.net> wrote:
> superpollo ha scritto:
>> hi.
>>
>> i have a text file, and i just wanted to get, say lines 3 thru 7, or
>> just line 7. my first guess is:
>>
>> cat | tail -n+3 | head -n+$((7-3+1))
>
> or:
>
> cat | tail -n+7 | head -n+1

What is this cat for? Is it doing anything useful, regarding that tail
can read file as well?

And why using tail|head combination when there are awk and sed which can
do the same without two processes?

--
Secunia non olet.
Stanislaw Klekot
From: superpollo on
Stachu 'Dozzie' K. ha scritto:
> On 2010-01-10, superpollo <utente(a)esempio.net> wrote:
>> superpollo ha scritto:
>>> hi.
>>>
>>> i have a text file, and i just wanted to get, say lines 3 thru 7, or
>>> just line 7. my first guess is:
>>>
>>> cat | tail -n+3 | head -n+$((7-3+1))
>> or:
>>
>> cat | tail -n+7 | head -n+1
>
> What is this cat for? Is it doing anything useful, regarding that tail
> can read file as well?
>

just a matter of style i think. are there performance drawdacks?

> And why using tail|head combination when there are awk and sed which can
> do the same without two processes?
>

can you explain please how can i use sed? or awk?

bye