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