Don't understand german? Read or subscribe to my english-only feed.

mika’s advent calendar – day 13: lesspipe

Displaying more with less:

lesspipe.sh is an input filter for the pager less as described in its man page. The script runs under a ksh compliant shell (ksh, bash, zsh) and allows to view files with binary content, compressed files, archives and files contained in archives. A large and growing number of formats are supported both as plain and compressed files using compress, gzip, bzip2, lzma, lzip or zip.

— quoting the homepage of lesspipe

If lesspipe.sh is present on your system and available in $PATH just use:

export LESSOPEN="|lesspipe.sh %s"

to enable it. Then you can use lesspipe through “the normal less command” like that:

% mkdir demo
% echo foo > demo/foo
% tar zcf demo.tgz demo/
% less demo.tgz
==> use tar_file:contained_file to view a file in the archive
drwxrwxr-x mika/mika         0 2008-12-11 23:49 demo/
-rw-rw-r-- mika/mika         4 2008-12-11 23:49 demo/foo
% less demo.tgz:demo/foo
foo

And of course lesspipe is available out-of-the-box at grml. ;)

Comments are closed.