Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

So Gilles mentioned in the chat room that:

less '+>' /path/to/file

can be used with less in order to view a file in reverse. I've never seen it before.

I'm curious - what's going on with the +> operator in the title? Is this less specific syntax? Can it be used otherwise? Are there similar operators I should probably know about?

share|improve this question
this command is effing dangerous in the hands of the sloppy. I ran it without the quotes around +> and ended up clobbering a file –  1_CR Apr 7 at 17:11
Well, warnings we give based on our own mistakes are sorely bought, but theyre definitely worth a vote. –  mikeserv Apr 7 at 17:13
I would say "to view the file from the end" rather than "in reverse" - </path/to/file tac | less would be "in reverse" to my ears. Also less +G /path/to/file should be promoted over '+>" since it has the same effect with fewer keystrokes and less danger of file clobbering for neophytes. –  D McKeon Apr 7 at 22:08

2 Answers 2

up vote 3 down vote accepted

It's less specific (you can guess this with the quotes around the operator to avoid the shell interpreting it). The + argument tells less to apply this command after opening the file, in this case > which is the keystroke for going to the end of the file. You can try this out by opening some (long) file with less and hitting >. +> is just a shortcut for this. A fairly more common use-case you'll find in the wild is calling less +## /path/to/file where ## is a line number you want to be displayed by less.

At least +## also works for vi and emacs.

share|improve this answer
So '+' passes keystrokes to less? I mean i knew was escaped for a reason - as in - i knew it wasnt shell syntax, but often similar types of programs share common operators and such. –  mikeserv Apr 7 at 17:03
Actually a command. Have a look at man less | less '+/\+cmd'. ;) –  Andreas Wiese Apr 7 at 17:06
man answers are my favorite answers –  mikeserv Apr 7 at 17:24
My sarcasm sense tickles. I was proud of this since the exact command line also helps demonstrates what's going on. When thinking about it further, commands and keystrokes in less are rather equal. –  Andreas Wiese Apr 7 at 17:31
No sarcasm - i must have said it in at least one other comment somewhere - look at the timing on my comment there and your first upvote. man answers are my favorite answers. And if you look at my own answers a lot of them are nothing but codeblocks at all. –  mikeserv Apr 7 at 17:32

A long long time ago, several programs understood the command line argument +N (e.g. +42) to mean “start at line N” (not “skip N lines”, but “skip N-1 lines”, because the first line is line 1). The oldest trace I can find is in tail in Unix V7, but I don't know for sure that this is where the usage started. An important program with the same option is more. Other programs that inherited this syntax from more include less, vi, and most other text editors today.

Over time, this syntax was progressively generalized. By 2.8BSD in 1980, more also supported +/PATTERN to start at the first line containing the specified pattern. By 2.10BSD in 1985, vi supported +COMMAND to run an arbitrary command on startup, generalizing +/PATTERN (not all versions of vi support this, and for example POSIX only specifies -c COMMAND, but it's supported by nvi, Elvis and Vim). The commands are ex commands, i.e. what you can type after :.

Less also supports the generalized +COMMAND (I don't know since when, but it was in the 20th century). In the case of +, it's as if you'd typed the characters as input after less starts, except in the special cases +N which is equivalent to +g and +/PATTERN where you can omit the final Return.

less '+>' /path/to/file is an example of that usage: execute the command > (go to the end of the file) after startup. You can also write less +G since G and > are synonyms. You can combine commands, for example less $'+>?foo\r' /path/to/file to go to the last occurrence of foo.

Another way to make Less execute commands on startup is to stuff them in the LESS environment variable: LESS='+>' less /path/to/file. This is useful if less is invoked by another program such as man (example: Reading and searching long man pages).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.