bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: Proposed new feature: head --show-truncation


From: Ed Avis
Subject: Re: Proposed new feature: head --show-truncation
Date: Thu, 21 Aug 2003 14:10:17 +0100 (BST)

On Thu, 21 Aug 2003, Stepan Kasal wrote:

>>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]]/'

Yes, that works, but it reads one more line of input than necessary
(whereas the implementation of --show-truncation reads at most one
extra byte).  Also, it won't work with --bytes.

I am finding it difficult to articulate the idea I have of whether an
option makes the command more powerful, as opposed to being redundant.  
Your script above pushes the work of counting lines to sed(1), in
other words being a reimplementation of all of head in sed, and so
doesn't count (no pun intended).

On the other hand, an option --number-lines to head would be redundant
because it can be done by piping through nl(1) first, and this piping
does not involve writing a new program to count lines or otherwise do
head's job.  The --line-number option to grep, however, is not
redundant, because you can't pipe through nl without sometimes
changing whether a regexp matches.

Perhaps nobody cares about such fine distinctions; perhaps what
matters most is that the option be useful.  Myself, I find it very
handy and it lets you use head much more often, piping from commands
like ls and diff without then having to run the command again to check
whether what you saw was the whole input.

-- 
Ed Avis <address@hidden>






reply via email to

[Prev in Thread] Current Thread [Next in Thread]