coreutils
[Top][All Lists]
Advanced

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

Re: Coreutils-gotchas


From: Pádraig Brady
Subject: Re: Coreutils-gotchas
Date: Sun, 29 Nov 2015 10:50:34 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 29/11/15 06:34, Assaf Gordon wrote:
> On 11/29/2015 12:16 AM, Pádraig Brady wrote:
> 
>>> I must collate some gotchas like this.
>>
>> Initial list started at:
>> http://www.pixelbeat.org/docs/coreutils-gotchas.html
>>
> 
> Fantastic list!
> 
> I would suggest adding four 'wc' entries:
> 
>   1. "wc -l" on a file with text but no new-line character will return zero.
> 
>       $ printf "hello world" | wc -l
>       0
> 
>   2. "wc -l" on a file in which the last line doesn't end with NL
>      will return a value of one-less than naively expected:
>     
>       $ printf "hello\nworld" | wc -l
>       1

This is the general case of 1.
It also applies to tac at least:

$ printf "1\n2" | tac
21

The other points are not unexpected I think given that -L counts display width.
But we did explain that badly thought for a long time :)
http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=v8.23-190-g79111d1
I've noted that better explanation in the list.

thanks,
Pádraig.



reply via email to

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