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


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?


Posted 2018-05-12T10:08:02.850

Reputation: 1 534

Your highlight section does not have : The back-slash is missing. Did you mean to? – mike65535 – 2018-05-12T11:04:20.680

@mike65535 , it is typed in, if you hit 'edit', you can see it. It doesn't get displayed though. – Aganju – 2018-05-12T12:45:07.693

Escaping the \ with another backslash should work. To short for me to edit though. – Orphevs – 2018-05-12T13:27:36.817



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


Posted 2018-05-12T10:08:02.850

Reputation: 283 655

1Which the tutorial's author apparently found too difficult to express in ordinary English. – user1686 – 2018-05-12T10:27:29.777

Well, it's is GNU... :P Excellent answer btw, popped up just as I began writing so good timing too! – bertieb – 2018-05-12T10:45:18.963

1Strictly speaking, the back-slash before the colon is relevant to bash, as it stops the colon from having a special meaning, which it doesn't have in bash, though it may in another shell. – AFH – 2018-05-12T10:46:55.863

1@grawity The context in the tutorial is: "Then look at the EXAMPLEs after the list of OPTIONS in man parallel (Use LESS=+/EXAMPLE: man parallel)". How would you have expressed it in ordinary English? – Ole Tange – 2018-05-12T23:29:52.520


As grawity's excellent answer indicates, it's a way of giving an instruction to the less pager. In this specific case, using the manual and tutorial of GNU Parallel, it makes reading the examples easy.

As you can see from even the table of contents in the online manual, each example starts with the string EXAMPLE:, so the command LESS=+/EXAMPLE: man parallel lets you jump to the fist example, and subsequent examples by pressing n (for next match).

For example:

screencap of jumping through manual

(each jump in manual section is a n keypress)


Posted 2018-05-12T10:08:02.850

Reputation: 6 181