Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Comments on Make Less use a normal view instead of hexdump view

Post

Make Less use a normal view instead of hexdump view

+4
−0

Less does not display data files normally, but if it were some sort of Xxd.

$ bash --norc
$ export LESS=
$ file -i /var/log/lastlog
/var/log/lastlog: application/octet-stream; charset=binary
$ less -EX /var/log/lastlog
00000000  a3 4c d2 60 74 74 79 32  00 00 00 00 00 00 00 00  |.L.`tty2........|
00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000474a0  ee c7 66 61 74 74 79 31  00 00 00 00 00 00 00 00  |..fatty1........|
000474b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000475c0  00 00 00 00                                       |....|
000475c4

Usually that is a good choice, but some data files are better read as normal text. How can I switch to the normal, plain text view in Less?

I have searched for "binary", "hex" and "xxd" in Less' manual but there does not seem to be a mention of it.


An update just to situate Canina's correct answer.

$ env | grep LESS
LESS=-iRj4
LESSOPEN=|lesspipe %s

lesspipe is a shell script with # Copyright 1999-2020 Gentoo Authors, so it is no surprise that many could not reproduce what I described.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

2 comment threads

norepro (2 comments)
What is in your ~/.bashrc? (2 comments)
norepro
Canina‭ wrote about 3 years ago · edited about 3 years ago

That's not what it does to me; with less 551, I get the expected semi-binary view rather than a hexdump-style view.

A few things of note:

That new bash session might not itself read the shell initialization files, but it's going to inherit the environment from the spawning shell. That could influence things.

You could have an alias for less that includes parameters. Try alias less or type less or use the full path explicitly for invocation. (which less if you're not sure where it is on your system, but should be /usr/bin/less or maybe /bin/less.)

less uses a number of environment variables, not just $LESS. Something like man less | tr ' ' $'\n' | grep ^LESS | sort --unique is imperfect, but provides a reasonable starting point. Also check env | grep ^LESS.

Quasímodo‭ wrote about 3 years ago

Canina‭ Thanks, indeed the problem was a different environment variable: LESSOPEN=|lesspipe %s. So either deleting that variable or using -L solves the problem. Would you like to write an answer?