[CentOS] logrotation

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

"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
preprocessor:

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

      #!/bin/bash
      case "$1" in
        *.Z)  uncompress -c $1 2>/dev/null
              ;;
        *.gz) gunzip -c $1 2>/dev/null
              ;;
      esac

      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
      things.

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

Best,

--- Les Bell, RHCE, CISSP
[http://www.lesbell.com.au]
Tel: +61 2 9451 1144
FreeWorldDialup: 800909