Sign up ×
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.

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

1 Answer 1

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


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