-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Chuck Simmons on 7/13/2007 9:31 PM: > 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.
Sorry, but POSIX does not specify these two programs symmetrically. POSIX only specifies head to support positive numbers (so as a GNU extension, we make the negative number count from the opposite direction). On the other hand, POSIX specifies tail's behavior for no sign, negative sign (both from the end), and positive sign (from the beginning). http://www.opengroup.org/onlinepubs/009695399/utilities/head.html http://www.opengroup.org/onlinepubs/009695399/utilities/tail.html So, what you want is: first portion of file: head -n 1 last portion of file: tail -n 1 all but first portion of file: head -n -1 all but last portion of file: tail -n +1 Yes, it is unfortunate, but that is because POSIX merely standardized existing practice, and 30 years of scripting would break if we were to change it now. > [EMAIL PROTECTED]:~$ tail --version > tail (GNU coreutils) 5.93 This is an old version. You may want to consider upgrading; the latest stable version is 6.9. - -- Don't work too hard, make some time for fun as well! Eric Blake [EMAIL PROTECTED] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGmEX184KuGfSFAYARAijVAJ9jG/A4tMrzmZ+sg0LG8EQOrip4YQCfQhkR gAqFP8Cm6bI9j0y8cE9aizs= =96ay -----END PGP SIGNATURE----- _______________________________________________ Bug-coreutils mailing list [email protected] http://lists.gnu.org/mailman/listinfo/bug-coreutils
