Viewing a .gz file directly using Less

one way to view a file in Linux is via Less, but what if you want to less a .gz file?

one way to do it is to extract the gz file then execute a Less on the extracted file,

however another method i would like to share is the LESSOPEN env variable.

Less will auto detect if the environment variable is present then uses it.

try executing in your command line.

export LESSOPEN="|gzip -cdfq %s"

then less a .gz file.

You wounldnt want to exec the export again again, you may automate this by including this in your bash profile

Enjoy the power of LESSOPEN!

1 Comment

  1. Chris

    zless and zcat area your friends, they are the equivalent of less and cat, only for gzipped files :)


Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>