Why does `less` treat my `.jpg` file as an image?

0
2
Asked By MellowCactus47 On

I'm trying to understand how Linux handles file extensions. Since Linux generally doesn't use extensions to determine a file's type, I created an empty file with `touch banana.jpg`, added plain text to it with `nano`, and confirmed the contents with `cat`.

However, running `less banana.jpg` produced a message like "No identify available" and suggested installing ImageMagick instead of showing the text. Why is `less` doing this, and how can I make it display the file contents normally?

1 Answer

Answered By QuietMango8 On

This is usually caused by `lesspipe`, a helper script that some distributions configure `less` to use. It can inspect filenames and extensions, then invoke other tools for compressed files, images, archives, and metadata. The `LESSOPEN` environment variable tells `less` which preprocessor to run, so the behavior depends on your distribution and its configuration.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.