Discussion:
bug#30504: bug tail -2 FILE1 FILE1 - tail: option used in invalid context -- 2
(too old to reply)
Mike Brescia
2018-02-17 20:57:14 UTC
Permalink
<oops update after typing paragraphs below>
searching archive with "invalid context" gets to "bug#8231: Bug in the linux command: tail"
I read the exchanges from 2011 and see where it went, but gripe that now I have to type extra characters to invoke it.
Perhaps I should fear that "head" will eventually be "broken" also.
</oops>

Attempting to use tail to get some number of lines other than default 10 on more than one file returns with error message "tail: option used in invalid context -- 2" or whatever N was used as arg.

head -N works fine

"aptitude" distribution on debian/linux --

$ tail --version
tail (GNU coreutils) 8.26

$ uname -a
Linux xymon-insp 4.9.0-5-amd64 #1 SMP Debian 4.9.65-3+deb9u2 (2018-01-04) x86_64 GNU/Linux

"homebrew" distribution on macos --

$ gtail --version
tail (GNU coreutils) 8.29

$ uname -a
Darwin DanteB.local 16.7.0 Darwin Kernel Version 16.7.0: Thu Jan 11 22:59:40 PST 2018; root:xnu-3789.73.8~1/RELEASE_X86_64 x86_64


I did check the FAQ, and tried the bug-mailing archive ( see <oops> above ). I think that the difference between "head" and "tail" operation with "-N" usage points to a bug in tail.

-- Mike
Paul Eggert
2018-02-17 22:37:32 UTC
Permalink
There is a backward-compatibility problem with supporting "tail -2" with any
number of extra arguments, since (for example) "tail -2c 20" has a different
meaning in traditional "tail" than you might think. To avoid confusion, "tail
-2" is not encouraged when using non-traditional features (in your case, two or
more FILE arguments). Since "tail -n2 FILE1 FILE2 ..." suffices, it's not clear
that it'd be worth the aggravation to rethink this.
Assaf Gordon
2018-10-30 02:48:06 UTC
Permalink
close 30504
stop

(triaging old bugs)
Post by Paul Eggert
There is a backward-compatibility problem with supporting "tail -2" with
any number of extra arguments, since (for example) "tail -2c 20" has a
different meaning in traditional "tail" than you might think. To avoid
confusion, "tail -2" is not encouraged when using non-traditional
features (in your case, two or more FILE arguments). Since "tail -n2
FILE1 FILE2 ..." suffices, it's not clear that it'd be worth the
aggravation to rethink this.
Given the above, and no further comments,
I'm closing this bug.

-assaf

Continue reading on narkive:
Loading...