coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Some question regarding tail and option "-c"


From: Jim Meyering
Subject: Re: Some question regarding tail and option "-c"
Date: Wed, 03 Oct 2012 20:09:26 +0200

Robert Milasan wrote:

> On Wed, 3 Oct 2012 11:18:59 -0600
> "Bob Proulx" <address@hidden> wrote:
>
>> What version of tail are you using?
>>
>>   tail --version
>>
>> I think the easiest way to see what is happening at run time is to use
>> strace.  Install it if you don't have it.  Then run:
>>
>>   cat /etc/passwd | strace -v -o tail.strace tail -c 10
>>
>> That should produce about a 14K output file with all of the system
>> calls logged.
>>
>
> # tail --version
> tail (GNU coreutils) 8.16
>
> # cat /etc/passwd | strace -v -o tail.strace tail -c 10
> tail: cannot open ‘10’ for reading: No such file or directory

I can reproduce that by specifying an older version of POSIX:

    $ : | _POSIX2_VERSION=0 tail -c 10
    tail: cannot open '10' for reading: No such file or directory

Depending on how your version of tail was compiled,
that may be the default behavior, or it may be due
to however your _POSIX2_VERSION envvar is set.

There is some documentation on the effects of that variable
in "info coreutils":

    2.13 Standards conformance
    ==========================

    In a few cases, the GNU utilities' default behavior is incompatible
    with the POSIX standard.  To suppress these incompatibilities, define
    the `POSIXLY_CORRECT' environment variable.  Unless you are checking
    for POSIX conformance, you probably do not need to define
    `POSIXLY_CORRECT'.

       Newer versions of POSIX are occasionally incompatible with older
    versions.  For example, older versions of POSIX required the command
    `sort +1' to sort based on the second and succeeding fields in each
    input line, but starting with POSIX 1003.1-2001 the same command is
    required to sort the file named `+1', and you must instead use the
    command `sort -k 2' to get the field-based sort.

       The GNU utilities normally conform to the version of POSIX that is
    standard for your system.  To cause them to conform to a different
    version of POSIX, define the `_POSIX2_VERSION' environment variable to
    a value of the form YYYYMM specifying the year and month the standard
    was adopted.  Three values are currently supported for
    `_POSIX2_VERSION': `199209' stands for POSIX 1003.2-1992, `200112'
    stands for POSIX 1003.1-2001, and `200809' stands for POSIX 1003.1-2008.
    For example, if you have a newer system but are running software that
    assumes an older version of POSIX and uses `sort +1' or `tail +10', you
    can work around any compatibility problems by setting
    `_POSIX2_VERSION=199209' in your environment.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]