less Command – How to Navigate to Next Found Result in Linux Log Files

lesslinux terminal

I have a log file where I can use less on the file where I know how to go to the bottom of the log file with a shift+G and then use ? to query in the text file.

What I don't know how to do is when I go to the bottom of the log file and find my first error or what I ever searching for with ? how I do get to the next one? From the bottom up I am hoping to go up and up and up on each error in the log file.

Best Answer

The answer is in the manual, man less:

       n      Repeat previous search, for N-th line containing the last
              pattern.  If the previous search was modified by ^N, the
              search is made for the N-th line NOT containing the
              pattern.  If the previous search was modified by ^E, the
              search continues in the next (or previous) file if not
              satisfied in the current file.  If the previous search was
              modified by ^R, the search is done without using regular
              expressions.  There is no effect if the previous search
              was modified by ^F or ^K.

       N      Repeat previous search, but in the reverse direction.