Search Command in Less: See Target Line in Context

  • Thread starter Thread starter nvn
  • Start date Start date
  • Tags Tags
    Search
AI Thread Summary
When using the Linux less command to view files, a common issue arises when the search command displays the target line at the top of the window, limiting context visibility. To resolve this, the less -jn option can be utilized, which allows the target line to appear lower in the window, specifically ensuring it is at least the fourth line down. This adjustment provides better context by displaying additional lines before and after the found string, enhancing the overall usability of the less command for file navigation.
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.
 
Technology news on Phys.org
Problem solved. The problem is solved by using the less -jn option, explained on the less man page.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...

Similar threads

Replies
1
Views
3K
Replies
5
Views
2K
Replies
8
Views
2K
Replies
2
Views
2K
Replies
26
Views
5K
Replies
5
Views
3K
Back
Top