[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#6605: +N lines broken with /usr/bin/tail (GNU coreutils) 7.4
From: |
Forest Oakwater |
Subject: |
bug#6605: +N lines broken with /usr/bin/tail (GNU coreutils) 7.4 |
Date: |
Sat, 10 Jul 2010 03:50:32 -0700 (PDT) |
Using this data file:
address@hidden:~/backgrounds/frazetta$ cat data.txt
line 1
line 2
line 3
line 4
and this command:
address@hidden:~/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:
address@hidden:~/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.
- bug#6605: +N lines broken with /usr/bin/tail (GNU coreutils) 7.4,
Forest Oakwater <=