Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I make less show the previous couple of lines when I search for something? I'd like to get rid of the kkk steps in my usual process:

  • /keyword
  • kkk
  • (read)
  • n
  • kkk
  • (read)
share|improve this question
up vote 3 down vote accepted
$ less -j 4 file

That will put the pattern you searched for on line 4 of the terminal.

To save typing this every time, you can put LESS=j4 into your environment.

share|improve this answer

Your Answer

 
discard

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