Bug 129388 - tail ignores options when -n or +n is specified, head demands a certain parameter order
tail ignores options when -n or +n is specified, head demands a certain param...
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: coreutils (Show other bugs)
i386 Linux
medium Severity high
: ---
: ---
Assigned To: Tim Waugh
: 134139 (view as bug list)
Depends On:
  Show dependency treegraph
Reported: 2004-08-07 11:03 EDT by Paul Moore
Modified: 2007-11-30 17:07 EST (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2004-08-10 08:09:56 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Paul Moore 2004-08-07 11:03:34 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.2)

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):

How reproducible:

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

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.
Comment 1 Paul Moore 2004-08-07 11:14:39 EDT
head seems to have a similar problem:
head -2 -q /tmp/a /tmp/b
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.
Comment 2 Tim Waugh 2004-08-10 08:09:56 EDT
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

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.
Comment 3 Tim Waugh 2004-09-30 04:33:52 EDT
*** Bug 134139 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.