How can I view gzipped files in less without having to type zless?
Use zcat
, then pipe it to less
.
$ zcat $FILE | less
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
:
#env
LESSOPEN=|/bin/lesspipe %s
I'm using IBM and when using zcat
, it will complains that it can't find the file ending with .Z
.
On IBM one can use gzcat
:
$ gzcat log_file.gz | less