[prev in list] [next in list] [prev in thread] [next in thread] 

List:       coreutils
Subject:    Re: minor 'cat' enhancement w/ patch
From:       Tom Warzeka <tom () waz ! cc>
Date:       2013-02-12 5:08:03
Message-ID: 5119CE33.1010903 () waz ! cc
[Download RAW message or body]

I didn't mean to imply that any other character would generally be better 
than '$'. I just thought there might be some utility in specifying the end 
character within 'cat' for whatever purpose a user might have, and I happen 
to use it with 'sed' for trailing white space detection.  However, I 
understand your rationale for not including this patch.  Thanks for the 
'grep' tips, though!

-- Tom

On 02/11/2013 10:57 AM, Pádraig Brady wrote:
> On 02/11/2013 03:29 PM, Pádraig Brady wrote:
>> On 02/11/2013 02:56 AM, Tom Warzeka wrote:
>>> Hello!  I sometimes use 'cat -E' as a quick check for lines with trailing
>>> white space.  I understand that '$' was chosen as the end-of-line
>>> character due to its usage in regular expressions.  However, I like to
>>> use a more conspicuous character, such as '@'.  So, I thought, how about
>>> letting the user specify the end-of-line character?  While doable with
>>> 'sed', it was quite easy to add an option to accomplish this.  My
>>> proposed new syntax is:
>>>
>>> cat -E -c @ ...
>>>
>>> or
>>>
>>> cat --show-ends --end-char=@ ...
>>>
>>> It is minimally intrusive and does not affect backward compatibility:
>>> when one of the new options is not specified, the end-of-line character
>>> is still '$'.  Alternatively, use of one of these options could
>>> automatically turn-on displaying an end-of-line character
>>> (just add "show_ends = true;" within the new case).
>>>
>>> Here's my patch submitted for your perusal.  It is applied to
>>> coreutils-8.20, the current latest stable release.  If you decide to
>>> include it, feel free to make any changes you see fit.  Thanks!
>>>
>>> -- Tom
>>
>> Why is @ (or any char) better than $ ?
>> If you wanted to highlight stuff you'd be better with grep or sed:
>>
>> cat -E < the/file | GREP_COLOR='30;41' grep --color '[[:space:]]*\$$'
>>
>> I don't think there is enough benefit for including this change.
>
> BTW if you're only interested in looking at trailing whitespace,
> then the trailing $, and thus `cat` is redundant anyway:
>
> # Show all lines with trailing whitespace highlighted
> $ GREP_COLOR='41' grep --color '[[:blank:]]*$'
>
> # Show lines with trailing whitespace highlighted
> $ GREP_COLOR='41' grep --color '[[:blank:]]\+$'
>
> cheers,
> Pádraig.
>




[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic