coreutils
[Top][All Lists]
Advanced

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

Re: minor 'cat' enhancement w/ patch


From: Pádraig Brady
Subject: Re: minor 'cat' enhancement w/ patch
Date: Mon, 11 Feb 2013 15:57:25 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1

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.



reply via email to

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