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

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

Proposed new feature: head --show-truncation


From: Ed Avis
Subject: Proposed new feature: head --show-truncation
Date: Sun, 17 Aug 2003 09:44:32 +0100 (BST)

head(1) produces the same output for an input of ten lines, and a
similar input of eleven lines where only the first ten are printed.  
It doesn't give an indication of whether what you see is the whole
file, or whether it is truncated.

Sometimes it would be useful to see this, for example when comparing
two files:

% diff -u a b | head -1000

You can see a reasonable amount of diffs, but there's no easy way to
tell whether this is all of them or whether there is more that hasn't
been printed.  Similarly, if grepping some files:

% find . -type f | xargs grep hello | head

Was that all the occurrences, or were there more?

The new feature is a --show-truncation flag which makes head print a
banner at the end of each file's output if the file has been
truncated.  The banner is similar in style to the one printed at the
top of each file with -v.  For example

% seq 0 3 | head --lines 3 --show-truncation
0
1
2
==> truncated standard input <==

% cd /usr/include
% head --lines 3 --show-truncation alloca.h assert.h
==> alloca.h <==
/* Copyright (C) 1992, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
   This file is part of the GNU C Library.

==> truncated alloca.h <==

==> assert.h <==
/* Copyright (C) 1991,1992,1994-1999,2000,2001 Free Software Foundation, Inc.
   This file is part of the GNU C Library.

==> truncated assert.h <==


I find this feature useful, and it seems natural - for example when
quoting the first few lines of output in a bug report you would
normally write '(truncated)' at the end to make things clear to the
reader.  Like the banners printed by head at the start of each file,
the extra information from --show-truncation is intended more for
human readers than for scripts.

What do you think?

-- 
Ed Avis <address@hidden>






reply via email to

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