From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.2) Gecko/20040301 Description of problem: If tail is given a +n or -n (where n is a number), the other valid options like -q, --quiet, -v, --verbose, do not work. Tail appears to accept only one parameter is +n or -n is specified, which makes it impossible for shell scripts to tail numerous files without pretty details about the file the data came from. Version-Release number of selected component (if applicable): coreutils-4.5.3-26 How reproducible: Always Steps to Reproduce: 1. echo -e 'a\nb\nc' > /tmp/a ; echo -e 'd\ne\nf' > /tmp/b 2. tail -2 /tmp/a /tmp/b # WORKS 3. tail -2 -q /tmp/a /tmp/b # FAILS Actual Results: tail: -q: No such file or directory Expected Results: b c e f Additional info: Also occurs when specifying the +n option. Also occurs when using --quiet instead of -q Also occurs when using -v and --verbose Also occurs when changing order of [+-]n and -option.
head seems to have a similar problem: head -2 -q /tmp/a /tmp/b a b d e head -q -2 /tmp/a /tmp/b head: invalid option -- 2 Try `head --help' for more information. Options should be accepted in either order. Severity changed to high because this has the potential to break numerous shell scripts.
The shell scripts should use "-n 2" instead of "-2". This (POSIX) way of specifying the option will work in both older and newer versions of head/tail. The documentation ('info coreutils head') documents the restriction you note on option ordering: On older systems, `head' supports an obsolete option `-COUNTOPTIONS', which is recognized only if it is specified first. COUNT is a decimal number optionally followed by a size letter (`b', `k', `m') as in `-c', or `l' to mean count by lines, or other option letters (`cqv'). POSIX 1003.1-2001 (*note Standards conformance::) does not allow this; use `-c COUNT' or `-n COUNT' instead.
*** Bug 134139 has been marked as a duplicate of this bug. ***