GNU bug report logs - #43282
tail -c +N / --bytes +N manpage wrong (off by 1)

Previous Next

Package: coreutils;

Reported by: "Martin Taibr" <Taibr <at> seznam.cz>

Date: Tue, 8 Sep 2020 15:55:03 UTC

Severity: normal

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Martin Taibr" <Taibr <at> seznam.cz>
To: <bug-coreutils <at> gnu.org>
Subject: tail -c +N / --bytes +N manpage wrong (off by 1)
Date: Tue, 08 Sep 2020 17:50:50 +0200 (CEST)
[Message part 1 (text/plain, inline)]
Currently the manpage says:





-c, --bytes=[+]NUM

              output the last NUM bytes; or use -c +NUM to output starting
with byte NUM of each file




Most (all?) hex editors number bytes from 0 so it's natural to assume tail -
c +0 will print the entire file, tail -c +1 will cut off the first byte and
so on. That's not the case, tail seems to "index" bytes from 1, not 0, so +0
and +1 both print the entire file.




I'd suggest

1) the manpage should mention counting starts from 1 (so you need to add 1
when copy pasting offsets from most other programs)


2) +0 should print a warning since its usage indicates the user likely
thinks tail counts from 0

3) -n / --lines docs should be changed to match (though counting lines from
1 is more common)
[Message part 2 (text/html, inline)]

This bug report was last modified 4 years and 286 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.