I would like to know how to view special characters while using 'less' command. For instance I want to see the non-printable characters with a special notation. For instance in 'vi' editor I use "set list on" to see the line termination characters represented by dollar '$' character. Similarly I would want to do this using 'less' command.
I referred Unix less manual, but to no avail.
For
less
use-u
to display carriage returns (^M
) and backspaces (^H
), or-U
to show the previous and tabs (^I
) for example:Without the
-U
switch the output would be:See
man less
for more exact description on the features.In the same spirit as https://stackoverflow.com/a/6943976/7154924:
cat -A
Alternatively, or at the same time, you can pipe to
tr
to substitute arbitrary characters to the desired ones for display, before piping to a pager likeless
if desired.All special, nonprintable characters are displayed using ^ notation in less. However, line feed is actually printable (just make a new line), so not considered special, so you'll have problems replacing it. If you just want to see line endings, the easiest way might be
less will look in its environment to see if there is a variable named LESS
You can set LESS in one of your ~/.profile (.bash_rc, etc, etc) and then anytime you run
less
from the comand line, it will find the LESS.Try adding this
This is the setup I use, there are some behaviors embedded in that may confuse you, so ...
You can find out about what all of these mean from the help function in
less
, just tap the 'h' key and nose around, or run less --help.edit
I looked at the help, and noticed there is also an -r option
I agree that cat may be the most exact match to your stated needs.
Will add '$' at end of each line and convert tab char to visual '^I'.
I hope this helps.
You can do that with cat and that pipe the output to less:
This excerpt from
man cat
explains what-e
means: