How do you run `less` and have it run a search pattern automatically?

You can use + to send arbitrary commands. E.g.:

less +/pattern

-p PATTERN (as posted by nik) is equivalent to +/PATTERN.


From the man page:

   -ppattern or --pattern=pattern
          The  -p  option  on the command line is equivalent to specifying
          +/pattern; that is, it tells less to start at the  first  occur-
          rence of pattern in the file.

This works as expected using the latest version of less (436).


You mean like?

less -p PATTERN filename

That is in the manual.

Tags:

Linux

Unix

Less