Search Command in Less: See Target Line in Context

  • Thread starter nvn
  • Start date
  • Tags Tags
    Search
1 reply · 2K views · last reply
nvn
Science Advisor
Homework Helper
Messages
2,128
Reaction score
32
When perusing a file using the linux less command, and you use the less search command inside less, I would like to know how to make less not display the line containing the target search string as the very top line of the session window (very poor design). I want the target line to always be at least the fourth line down from the top of the window (or lower), so I can see the found string in context, showing a few lines before (and after) the target line. Any help would be appreciated.
 
Problem solved. The problem is solved by using the less -jn option, explained on the less man page.