Getting less to stop highlighting non-ascii characters

1

I have some logs which I want to read in less. Unfortunately, scattered throughout the otherwise text file are some non-ascii characters that less displays as highlighted junk. This is really annoying.

How do I get rid of the highlighting?

pythonic metaphor

Posted 2010-03-08T22:58:25.893

Reputation: 2 046

Answers

2

There doesn't appear to be an option for it. Your choices then are (a) build your own modified version of less, and (b) filter those characters out before less gets hold of them, like this:

LANG= tr -cd '[:print:]' <yourfile | less

LANG is unset so that tr doesn't try to combine control characters into multibyte characters.

Peter Westlake

Posted 2010-03-08T22:58:25.893

Reputation: 996

5

Or use:

less -r

(display raw characters, if your terminal supports that)

asoundmove

Posted 2010-03-08T22:58:25.893

Reputation: 423

I can confirm this worked for me (less version 418, OS X Yosemite v10.10.5) – waldyrious – 2016-08-15T13:35:25.747

0

A nice workaround: use view instead of less. It opens the file in the vim editor in read-only mode.

The basic shortcut for text search remain the same as in less, i.e. /, n, N. To exit use :q.

Honza Zidek

Posted 2010-03-08T22:58:25.893

Reputation: 297