Problems with 'tail -n *'

Eric Blake ebb9@byu.net
Wed Oct 29 18:05:00 GMT 2008


Gustavo Seabra <gustavo.seabra <at> gmail.com> writes:


> >> $ tail -2 *.dat
> 
> OK, I see that now. Thanks. But is there a reason why the abbreviation
> is not working in cygwin? It works just fine in a different system...

It may be due to how many files that glob expands to, as the obsolete syntax 
works when *.dat expands to one file, but fails when it expands to multiple 
files.

And is your different system running GNU coreutils?  The difference may also be 
due to what level of POSIX compliance the tail implementation provides.

Read 'info tail':

   For compatibility `tail' also supports an obsolete usage `tail
-[COUNT][bcl][f] [FILE]', which is recognized only if it does not
conflict with the usage described above.  This obsolete form uses
exactly one option and at most one file.  In the option, COUNT is an
optional decimal number optionally followed by a size letter (`b', `c',
`l') to mean count by 512-byte blocks, bytes, or lines, optionally
followed by `f' which has the same meaning as `-f'.
...
   Even if your script assumes the standard behavior, you should still
beware usages whose behaviors differ depending on the POSIX version.
For example, avoid `tail - main.c', since it might be interpreted as
either `tail main.c' or as `tail -- - main.c'; avoid `tail -c 4', since
it might mean either `tail -c4' or `tail -c 10 4'; and avoid `tail +4',
since it might mean either `tail ./+4' or `tail -n +4'.

-- 
Eric Blake




--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list