LESSOPEN(1)
โจ LESSOPEN(1) โ General Commands Manual โจ
Okay so bestie, this is the manual page for lessfile and lesspipe ๐ They're the "input preprocessor" for less, and honestly? Iconic. ๐
๐ NAME
lessfile, lesspipe โ "input preprocessor" for less.
๐ฆ SYNOPSIS
lessfile, lesspipe
๐ DESCRIPTION
Okay so this page briefly documents the lessfile and lesspipe commands. It was written for the Debian GNU/Linux distribution because the input preprocessor scripts are provided by Debian GNU/Linux and are not part of the original program. Not me being extra about the credits, just being accurate ๐
lessfile and lesspipe are programs that modify the way the contents of a file get displayed in less. Main character energy! less can automatically open up tar files, uncompress gzipped files, and even display something reasonable for graphics files. โจ
lesspipe will toss the contents/info on STDOUT and less will read them as they come across. So you do not have to wait for the decoding to finish before less shows you the file. ๐ The catch is that you get a 'byte N' instead of an N% as your file position. You can seek to the end and back to get the N%, but that means you have to wait for the pipe to finish. Lowkey a tradeoff, fr fr.
lessfile will toss the contents/info on a file which less will then read. After you are done, lessfile will then delete the file. This means the process has to finish before you see anything, but you get nice percentages (N%) up front. ๐
๐ธ USAGE
Just put one of the following two commands in your login script (e.g. ~/.bash_profile):
eval "$(lessfile)"
or
eval "$(lesspipe)"
๐ FILE TYPE RECOGNITION
Okay, so file types are recognized by their extensions. Here's the list of currently supported extensions, grouped by the programs that handle them ๐ซถ
*.a
*.arj
*.tar.bz2
*.bz
*.bz2
*.deb, *.udeb, *.ddeb
*.doc
*.egg
*.gif, *.jpeg, *.jpg, *.pcd, *.png, *.tga, *.tiff, *.tif
*.iso, *.raw, *.bin
*.lha, *.lzh
*.tar.lz, *.tlz
*.lz
*.7z
*.pdf
*.rar, *.r[0-9][0-9]
*.rpm
*.tar.gz, *.tgz, *.tar.z, *.tar.dz
*.gz, *.z, *.dz
*.tar
*.tar.xz, *.xz
*.whl
*.jar, *.war, *.xpi, *.zip
*.zoo
*.tar.zst, *.tzst
*.zst
๐ง USER DEFINED FILTERS
It's possible to extend and overwrite the default lesspipe and lessfile input processor if you have specialized requirements. Create an executable program named .lessfilter and put it into your home directory. It can be a shell script or a binary program. Customization slay. ๐ฅ
It is important that this program returns the correct exit code: return0if your filter handles the input, return1if the standardlesspipe/lessfilefilter should handle the input.
Here's an example script bestie:
#!/bin/sh
case "$1" in
*.extension)
extension-handler "$1"
;;
*)
# We don't handle this format.
exit 1
esac
# No further processing by lesspipe necessary
exit 0
๐ FILES
~/.lessfilter : Executable file that can do user defined processing. See section USER DEFINED FILTERS for more information.
๐ BUGS
Sometimeslessdoes not display the contents file you want to view, but output produced by your login scripts (~/.bashrcor~/.bash_profile) instead. ๐ This happens becauselessuses your current shell to run thelesspipefilter. Bash first looks for the variable$BASH_ENVin the environment, expands its value, and uses the expanded value as the name of a file to read and execute. If this file produces any output,lesswill display it. To fix this, put the following lines at the top of your login script that produces output:
if [ -z "$PS1" ]; then
exit
fi
This tests whether the prompt variable $PS1 is set. If it isn't (which is the case for non-interactive shells), it will exit the script. ๐ซถ
๐ SEE ALSO
๐ AUTHOR
This manual page was written by Thomas Schoepf <schoepf@debian.org>, for the Debian GNU/Linux system (but may be used by others). Most of the text was copied from a description written by Darren Stalder <torin@daft.com>. ๐
Bestie, you made it to the end! ๐ Source: General Commands Manual, LESSOPEN(1) ๐ Stay gorgeous, stay curious, and go read your files with less ๐โจ
๐ฆ where this page comes from
- debian bookworm: less 590-2.1~deb12u2 ยท GPL-3.0-or-later OR Less
- debian trixie: less 668-1 ยท GPL-3.0-or-later OR Less
- ubuntu jammy: less 590-1build1
- ubuntu jammy: less 590-1ubuntu0.22.04.3
- ubuntu noble: less 590-2ubuntu2 ยท GPL-3.0-or-later OR Less
- ubuntu noble: less 590-2ubuntu2.1 ยท GPL-3.0-or-later OR Less
- ubuntu questing: less 668-1 ยท GPL-3.0-or-later OR Less
- ubuntu resolute: less 668-1build1 ยท GPL-3.0-or-later OR Less
- ubuntu stonking: less 668-1build1 ยท GPL-3.0-or-later OR Less
- ๐ girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms