Adam Turoff on Sun, 3 Feb 2002 22:00:26 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] not head, not tail, but what?


On Sun, Feb 03, 2002 at 03:13:57PM -0500, Kyle R . Burton wrote:
> Is there a standard utility out there that can print out all the lines
> from a file except the first n?

Not a common operation, so it's not a common tool, but a common idiom:

	sed -e '1,n d' filename
	perl -ne 'print if $. > n' filename

> Head can get you the first n, tail can get you the last n.  Is there
> something that can get you m-n?

Play with the range n and n-m (e.g. to get the range 5-9):
	head -9 filename | tail -4

or just use sed/perl again

	sed -e '5-9 p; d' filename
	perl -ne 'print if $. >= 5 and $. <= 9' filename
 
> I know this kind of utility would be easy to write, but it feels like
> it should already exist...

It sorta does, but not as a standalone program.

Z.


______________________________________________________________________
Philadelphia Linux Users Group       -      http://www.phillylinux.org
Announcements-http://lists.phillylinux.org/mail/listinfo/plug-announce
General Discussion  -  http://lists.phillylinux.org/mail/listinfo/plug