[mod.std.unix] tail in 1003.2 Commands

std-unix@ut-sally.UUCP (Moderator, John Quarterman) (01/18/87)

From: colonel@sunybcs.UUCP (Col. G. L. Sicherman)
Date: 12 Jan 87 15:18:10 GMT
Organization: Jack of Clubs Precision Instruments

> From: hoptoad!gnu@lll-crg.arpa (John Gilmore)
> Date: Sat, 27 Dec 86 02:57:15 PST
> 
> ... Tail should be in the mandatory set of commands.

I know that tail is in BSD.  Is it a Berkeley product?  There's one thing
about it I don't like.  When you type "tail +10c" you get all characters
starting with the tenth.

Now, that's un-Unixican.  Characters start at 0, and perhaps blocks and
lines should too.  As it is, if I want a shell command or expression
in the argument, I usually have to add 1 to it to make it work.

I'd like to see a program that does what tail does, except that if
you say "tail +n" it skips the first n units.  You could call it
something else--maybe "trail."  And how about a "head" with the same
syntax as tail/trail?  ("head xx file; tail xx file" = "cat file")
-- 
Col. G. L. Sicherman
UU: ...{rocksvax|decvax}!sunybcs!colonel
CS: colonel@buffalo-cs
BI: colonel@sunybcs, csdsiche@ubvms

Volume-Number: Volume 9, Number 20

std-unix@ut-sally.UUCP (01/28/87)

From: decwrl!nsc!nsc!nsta!instable.ether!amos (Amos Shapir)
Date: Mon, 19 Jan 87 16:54:53 -0200
Organization: National Semiconductor (Israel) Ltd.

>From: colonel@sunybcs.UUCP (Col. G. L. Sicherman)
>I'd like to see a program that does what tail does, except that if
>you say "tail +n" it skips the first n units.  You could call it
>something else--maybe "trail."  And how about a "head" with the same
>syntax as tail/trail?  ("head xx file; tail xx file" = "cat file")

Try 'dd bs=n skip=1' - actually, what you need is a 'line' modifier to
dd, in addition to chars, blocks and k.
-- 
	Amos Shapir
National Semiconductor (Israel)
6 Maskit st. P.O.B. 3007, Herzlia 46104, Israel
(011-972) 52-522261  amos%nsta@nsc 34.48'E 32.10'N

Volume-Number: Volume 9, Number 25

std-unix@ut-sally.UUCP (01/30/87)

From: guy%gorodish@Sun.COM (Guy Harris)
Date: 29 Jan 87 07:20:35 GMT
Reply-To: guy@sun.UUCP (Guy Harris)
Organization: Sun Microsystems, Mountain View

>>From: colonel@sunybcs.UUCP (Col. G. L. Sicherman)
>>I'd like to see a program that does what tail does, except that if
>>you say "tail +n" it skips the first n units.

	sed -n '<n>,$p'

will do the job quite nicely.

>>And how about a "head" with the same syntax as tail/trail?
>>("head xx file; tail xx file" = "cat file")
>
>Try 'dd bs=n skip=1' - actually, what you need is a 'line' modifier to
>dd, in addition to chars, blocks and k.

Well, 4BSD has such a "head" command, and writing one for systems
lacking it would probably take less work than adding a "line"
modifier to "dd" (which would be totally inappropriate for "dd", just
as "-v" is inappropriate for "cat").  On the other hand,

	sed -n '1,<n>p'

will do the job quite nicely here, too.  (I suspect it may still read
the rest of the file, but sticking in optimizations to avoid this are
left as an exercise to the reader.)

Let's not use 1003.2 as a chance to add every feature we want to some
UNIX command, or to tweak their behavior to fit something that seemed
convenient one day last month, or to add our favorite command.  The
commands standardized in 1003.2 should be *tools* - such as, to pick
a random example, "sed".

Volume-Number: Volume 9, Number 35