By default, forward searches start at the top of the displayed screen and backwards searches start at the bottom of the displayed screen (except for repeated searches invoked by the n or N commands, which start after or before the “target” line respectively; the -j option for more about the target line). The -a option causes forward searches to instead start at the bottom of the screen and backward searches to start at the top of the screen, thus skipping all lines displayed on the screen.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
## create a long file with 200 lines > myfile; i=1; while [ $i -le 200 ]; \ do echo "$i" >> myfile; ((i++)); done ## less -a or --search-skip-screen less -a myfile ## in the interactive mode type /9 to ## perform a forward search for 9 ## forward search starts from 49 (located on next screen) ## may change according to your screen size ## default less myfile ## in the interactive mode type /9 to ## perform a forward search for 9 ## forward search starts from 9 (located on current screen) rm myfile |