[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Proposed new feature: head --show-truncation
From: |
Stepan Kasal |
Subject: |
Re: Proposed new feature: head --show-truncation |
Date: |
Thu, 21 Aug 2003 14:29:14 +0200 |
User-agent: |
Mutt/1.2.5.1i |
Hello,
On Thu, Aug 21, 2003 at 12:55:30PM +0100, Ed Avis wrote:
> I can't get this command to work:
> Label too long: 2!b;n;s/.*/[[trunc]]/;q
I apologize; the following versions should be more portable:
sed -e '2!b' -e 'n;s/.*/[[trunc]]/;q'
sed -e '2{' -e 'n;s/.*/[[trunc]]/;q;}'
sed '1,2p;1,2d;s/.*/[[trunc]]/;q'
> >I mean that trivial shell script which doesn't use "head" should
> >also count.
>
> No, because by that argument at least half of the classic Unix
> utilities would be eliminated.
They are "clasic" because they were born in times when they were
significantly quicker then their shell counterparts.
(Perl was just a jewel with a typo in those times.)
> I am hoping to consider whether the
> --show-truncation flag makes head more powerful, in that it couldn't
> be emulated by the existing head plus a couple of lines of
> shell.
Well, here is one script
n=2
n1=`expr $n + 1`
head -n $n1 | sed $n1's/.*/[[trunc]]/'
and here is another:
n=2
head -n $n ; sed 's/.*/[[trunc]]/;q'
The later one works only if the input is seekable.
In other words, POSIX doesn't guarantee that it'll work with input
from a pipe, for example.
Yours,
Stepan