Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using Ubuntu, and I would like to be able to type less compressed_text_file.gz and page the contents of the text file in uncompressed form. Is there a way to do this?

share|improve this question
up vote 18 down vote accepted

You can configure the key bindings and set many settings for less in a file called ~/.lesskey. Once you've created the file, run the lesskey command; it generates a file called ~/.less which less reads when it starts.

The setting you want is LESSOPEN. It's an input formatter for less. The less package comes with a sample formatter in /bin/lesspipe; it decompresses gzipped files, shows content listings for many multi-file archive formats, and converts several formatted texts formats to plain text. In your ~/.lesskey:

LESSOPEN=|/bin/lesspipe %s
share|improve this answer

Use zcat, then pipe it to less.

$ zcat $FILE | less
share|improve this answer
I would prefer if less just worked on compressed files. – Ryan Thompson May 6 '11 at 18:37
Unlike the accepted answer this one is a clean and unix-way solution. Thanks! – Pavel Vlasov Dec 8 '14 at 11:43

On some distros, try

zless compressed_text_file.gz
share|improve this answer
Did you even read the question title? – Ryan Thompson Mar 8 at 14:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.