From: superpollo on 10 Jan 2010 07:15 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 10 Jan 2010 07:16 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 10 Jan 2010 07:13 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 10 Jan 2010 07:21 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 10 Jan 2010 07:25
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 |