Reading pdf files from the terminal with less

The good old less command can be used to open more than plain text files. All you need is to set the LESSPIPE environment variable to pipe the /usr/bin/lesspipe script in your .bashrc or .zshrc file. In most systems, the lesspipe script is pre-installed. Otherwise you can download it from here.

export LESSOPEN='|/usr/bin/lesspipe %s'

Now simply open your pdf files with less.

less abc.pdf

Besides from pdf files you can pipe in compressed files (like tar.gz, zip, rar, etc), ISO files and even .doc files. But who uses .doc files anyway? :mrgreen:

Post a comment or leave a trackback: Trackback URL.

Leave a Reply

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