GNU bug report logs -
#6605
+N lines broken with /usr/bin/tail (GNU coreutils) 7.4
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 6605 in the body.
You can then email your comments to 6605 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#6605
; Package
coreutils
.
(Sat, 10 Jul 2010 16:30:04 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Forest Oakwater <forest_oakwater <at> yahoo.com>
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Sat, 10 Jul 2010 16:30:04 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Using this data file:
dad <at> elrond:~/backgrounds/frazetta$ cat data.txt
line 1
line 2
line 3
line 4
and this command:
dad <at> elrond:~/backgrounds/frazetta$ /usr/bin/tail +2 data.txt
/usr/bin/tail: cannot open `+2' for reading: No such file or directory
==> data.txt <==
line 1
line 2
line 3
line 4
Output was incorrect. The manpage and builtin help text both state:
dad <at> elrond:~/backgrounds/frazetta$ /usr/bin/tail --help
...
-n, --lines=N output the last N lines, instead of the last 10;
or use +N to output lines starting with the Nth
...
According to the documentation (and my previous experience shell scripting) It should have printed the tail of data.txt starting with the 2nd line, like this:
line 2
line 3
line 4
Looks like it just needs a little code near the getopt() call (or however the command line is parsed) to recognize "+" as an option indicator.
This is useful for example to implement a stack:
function pop
{
FILENAME=`head -1 data.file`
tail +2 data.file > data.file.tmp
mv data.file.tmp data.file
}
function push
{
echo "$FILENAME" > data.file.line1
cat data.file.line1 data.file > data.file.tmp
mv data.file.tmp data.file
}
Thanks for your attention.
[Message part 2 (text/html, inline)]
Information forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#6605
; Package
coreutils
.
(Sat, 10 Jul 2010 20:07:02 GMT)
Full text and
rfc822 format available.
Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):
On Sat, 10 Jul 2010 03:50:32 -0700 (PDT) Forest Oakwater
<forest_oakwater <at> yahoo.com> wrote:
> Using this data file:
> dad <at> elrond:~/backgrounds/frazetta$ cat data.txt
> line 1
> line 2
> line 3
> line 4
>
> and this command:
> dad <at> elrond:~/backgrounds/frazetta$ /usr/bin/tail +2 data.txt
> /usr/bin/tail: cannot open `+2' for reading: No such file or directory
> ==> data.txt <==
> line 1
> line 2
> line 3
> line 4
>
> Output was incorrect. The manpage and builtin help text both state:
>
> dad <at> elrond:~/backgrounds/frazetta$ /usr/bin/tail --help
> ...
> -n, --lines=N output the last N lines, instead of the last
> 10; or use +N to output lines starting with the Nth
> ...
This is not what you did. You did "tail +2", whereas the man says you
should do "tail -n +2", or "tail --lines=+2". If you want to output the
last N lines, rather than starting from the Nth, you'd do "tail -n 2" or
"tail --lines=2".
The "tail +2" syntax is obsolete; probably the recent versions of coreutils
(which 7.4 is not, anyway) dropped support for it.
--
D.
Information forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#6605
; Package
coreutils
.
(Mon, 12 Jul 2010 18:47:02 GMT)
Full text and
rfc822 format available.
Message #11 received at submit <at> debbugs.gnu.org (full text, mbox):
On 07/10/10 12:53, Davide Brini wrote:
> The "tail +2" syntax is obsolete; probably the recent versions of coreutils
> (which 7.4 is not, anyway) dropped support for it.
It's not just obsolete: it's incompatible with POSIX 1003.1-2001,
which is why it was dropped a while ago. You can bring back
support for "tail +2" by setting _POSIX2_VERSION=199209 in
your environment; this is documented in the coreutils manual.
But it's probably better to update those dusty old shell scripts
to use the POSIX-specified syntax.
Information forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#6605
; Package
coreutils
.
(Thu, 15 Jul 2010 20:35:02 GMT)
Full text and
rfc822 format available.
Message #14 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Paul,
Thank you for the information. Would you consider updating the builtin documentation and man page to match the behavior of the program?
Also, do you know of an efficient POSIX way to filter out the first N lines of a text file?
# inefficient?
head -N datafile > datafile.head
diff datafile.head datafile |grep '^>' |cut -c3- > datafile.new
mv datafile.new datafile
Thanks,
Forest
--- On Mon, 7/12/10, Paul Eggert <eggert <at> CS.UCLA.EDU> wrote:
From: Paul Eggert <eggert <at> CS.UCLA.EDU>
Subject: Re: bug#6605: +N lines broken with /usr/bin/tail (GNU coreutils) 7.4
To: forest_oakwater <at> yahoo.com
Cc: bug-coreutils <at> gnu.org
Date: Monday, July 12, 2010, 2:46 PM
On 07/10/10 12:53, Davide Brini wrote:
> The "tail +2" syntax is obsolete; probably the recent versions of coreutils
> (which 7.4 is not, anyway) dropped support for it.
It's not just obsolete: it's incompatible with POSIX 1003.1-2001,
which is why it was dropped a while ago. You can bring back
support for "tail +2" by setting _POSIX2_VERSION=199209 in
your environment; this is documented in the coreutils manual.
But it's probably better to update those dusty old shell scripts
to use the POSIX-specified syntax.
[Message part 2 (text/html, inline)]
Information forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#6605
; Package
coreutils
.
(Thu, 15 Jul 2010 21:16:01 GMT)
Full text and
rfc822 format available.
Message #17 received at submit <at> debbugs.gnu.org (full text, mbox):
Forest Oakwater wrote:
> Thank you for the information. Would you consider updating the
> builtin documentation and man page to match the behavior of the
> program?
You say that like it doesn't match now. :-) But it does. You even
quoted the important parts in your original message.
You wrote:
> -n, --lines=N output the last N lines, instead of the last 10;
> or use +N to output lines starting with the Nth
So I know you have an older version of the program with the older
version of the online docs. But those are strictly correct! The
confusion you are experiencing comes from the -n using 'n' and the
--lines=N using 'N'. Some time in the last while there was another
discussion of this (it will be in the archive but I don't have time to
look) we decided to change this to K to make it more obvious. The
current online documentation says:
-n, --lines=K output the last K lines, instead of the last 10;
or use -n +K to output lines starting with the Kth
If the first character of K (the number of bytes or lines) is a `+',
We thought it was more clear to use 'K' instead to avoid any confusion
of N with -n. But as you can see with K it still says about the same
thing. If you want to use a +NUM then you need to say 'tail -n +2' or
some such. So the older documentation is correct and the newer
documentation is both correct and more helpful.
> Also, do you know of an efficient POSIX way to filter out the first
> N lines of a text file?
I personally like sed for this.
sed 1,2d FILE
Or:
sed -n '3,$p' FILE
> # inefficient?
> head -N datafile > datafile.head
> diff datafile.head datafile |grep '^>' |cut -c3- > datafile.new
> mv datafile.new datafile
Please, my eyes, the pain! :-}
Bob
Information forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#6605
; Package
coreutils
.
(Thu, 15 Jul 2010 21:21:02 GMT)
Full text and
rfc822 format available.
Message #20 received at submit <at> debbugs.gnu.org (full text, mbox):
On 07/15/10 13:34, Forest Oakwater wrote:
> Would you consider updating the builtin
> documentation and man page to match the behavior of the program?
That's already the case, surely.
> Also, do you know of an efficient POSIX way to filter out the first N
> lines of a text file?
"tail -n +51", "sed 1,50d", "awk '50 < NR'"; take your pick.
Information forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#6605
; Package
coreutils
.
(Thu, 15 Jul 2010 21:42:02 GMT)
Full text and
rfc822 format available.
Message #23 received at submit <at> debbugs.gnu.org (full text, mbox):
On Thu, 15 Jul 2010 13:34:50 -0700 (PDT) Forest Oakwater
<forest_oakwater <at> yahoo.com> wrote:
> Paul,
>
> Thank you for the information. Would you consider updating the builtin
> documentation and man page to match the behavior of the program?
It *is* correct. Nowhere it says that you can use "tail -2" or "tail +2".
Instead it says that you should use
"tail -n N", or "tail --lines=N" (or +N if you want from line N).
> Also, do you know of an efficient POSIX way to filter out the first N
> lines of a text file?
>
> # inefficient?
> head -N datafile > datafile.head
> diff datafile.head datafile |grep '^>' |cut -c3- > datafile.new
> mv datafile.new datafile
Dozens, all probably just as efficient as using tail -n +N.
--
D.
Reply sent
to
Bob Proulx <bob <at> proulx.com>
:
You have taken responsibility.
(Thu, 25 Aug 2011 05:41:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Forest Oakwater <forest_oakwater <at> yahoo.com>
:
bug acknowledged by developer.
(Thu, 25 Aug 2011 05:41:02 GMT)
Full text and
rfc822 format available.
Message #28 received at 6605-done <at> debbugs.gnu.org (full text, mbox):
> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6605
It has been a year since any feedback has been provided on this issue
in the bug tracking system. I believe that the discussion logged so
far was sufficient to fully resolve the issue. Therefore I am closing
this bug. Feel free to follow-up with more information if desired.
Bob
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 22 Sep 2011 11:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 13 years and 280 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.