What does `LESS=+/EXAMPLE\:` mean

lessmansymbols

In man parallel_tutorial (for GNU parallel) I’ve found the following black magic:

LESS=+/EXAMPLE\: man parallel

Searching around in the man pages for man, less, and bash, it appears this may have something to do with a less preprocessor, but I’m not sure, and the first few attempts I made to search other manual pages with this syntax failed.

What does +/...\: mean in bash?

Best Answer

It doesn't mean anything in bash. It's some arbitrary text that gets stored in the $LESS environment variable for that single command.

But when you run less, it reads the contents of $LESS and interprets them much like command-line arguments. Usually this is where you'd store configuration for it.

(less is not a preprocessor: it's a simple text file viewer, aka a pager. Note that man has no built-in reader: it just generates the text via groff (the actual preprocessor), then always runs either less or some other pager to scroll through it. The authors of that tutorial assume your system will be using less because it's so ubiquitous.)

When less encounters arguments starting with a +, the remainder is further interpreted as commands or keypresses to simulate: e.g. if it were +G then less would pretend you had pressed G after opening the file, and would scroll down.

In your case, less pretends you had typed /EXAMPLE: after opening the file. / is the search key/command in less, and the rest is the text to search for.

The result is that the command opens the manpage of "parallel", then scrolls down to the section titled "EXAMPLE".

Related Question