Re: remove last and first three lines from a file
From: Robert Katz (katz_at_hp.com)
Date: Tue, 28 Dec 2004 19:44:34 GMT
John Savage wrote:
> "Prince" <firstname.lastname@example.org> writes:
>>I forgot to mention, the dificulty I have is deleting the last three
>>lines. I can use sed '1,3d' to delete the first three.
> Any great need for efficiency? If not ....
> sed '1,3d;$d' datafile | sed '$d' | sed '$d'
> or, sed '1d;$d' datafile | sed '1d;$d' | sed '1d;$d'
In classical sed, not GNU, in which
"If no next line of input is available, the N command verb shall branch
to the end of the script and quit without starting a new cycle or
copying the pattern space to standard output."
This is not as easily generalized as the awk routine.
-- Regards, ---Robert