[CentOS] logrotation

Les Bell lesbell at lesbell.com.au
Fri Oct 19 08:04:23 UTC 2007

"umair shakil" <umairshakeel at gmail.com> wrote:

when i use less command to see this gz file it says "do u want to see
binary file??"
through which utility i can see the contants of the file???

All right, I'll bite. You could use zcat. But if you really want to use
less to *automatically* unzip a .gz file, then you can create a less

      Use vi to create /usr/local/bin/lesspipe.sh and type in the following

      case "$1" in
        *.Z)  uncompress -c $1 2>/dev/null
        *.gz) gunzip -c $1 2>/dev/null

      Make the lesspipe.sh file executable ('chmod +x
      /usr/local/bin/lesspipe.sh') and then create a LESSOPEN environment
      variable to make less use it:

      export LESSOPEN="|/usr/local/bin/lesspipe.sh %s"

      Test that this works, by cd'ing to /usr/doc/HOWTO, and if all is OK,
      add the export line to /etc//bashrc so that it takes permanent
      effect. Obviously, the lesspipe.sh script can be extended to do other

All this is basically in the less man page, of course.


--- Les Bell, RHCE, CISSP
Tel: +61 2 9451 1144
FreeWorldDialup: 800909

More information about the CentOS mailing list