GNU bug report logs -
#6605
+N lines broken with /usr/bin/tail (GNU coreutils) 7.4
Previous Next
Full log
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)]
This bug report was last modified 13 years and 294 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.