bug-coreutils
[Top][All Lists]
Advanced

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

head and tail


From: Chuck Simmons
Subject: head and tail
Date: Fri, 13 Jul 2007 20:31:12 -0700

"man tail" on my ubuntu box says to report bugs to this address.


Since head and tail have similar functionality, they should respond to
similar command line arguments in similar ways except that one command does
the head of the file and one does the tail.

Specifically, 'man head' says that either "-n -1" or "--lines=-1" would
print all lines of the file except the last line.  (And, indeed, this
works.)  So, we would expect that 'tail -n -1 filename' would print all but
the first line.  In actual practice, the man page suggests that you cannot
specify a negative number, and the command prints out the last line of the
file.

Ideally 'tail -n -1' should print out the first line of the file and the man
page should be updated.  Alternatively, one could modify 'tail' to generate
an error when a negative value is specified.


address@hidden:~$ cat << END >/tmp/afile
a
b
c
END
address@hidden:~$ head -n -1 /tmp/afile
a
b
address@hidden:~$ tail -n -1 /tmp/afile
c
address@hidden:~$ tail --version
tail (GNU coreutils) 5.93
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software.  You may redistribute copies of it under the terms of
the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
There is NO WARRANTY, to the extent permitted by law.

Written by Paul Rubin, David MacKenzie, Ian Lance Taylor, and Jim Meyering.



Cheers, Chuck


reply via email to

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