I prefer to use less command to view files because less don’t require to load the
whole file before viewing. In this article, let us look at few less command navigation.
Once you open a log file (or any file) using
Once you open a log file (or any file) using
less file-name
, use the
following keys to search. Please note that the match will be highlighted automatically.
Forward Search
/
Search for a pattern which will take you to the next occurrence.n
For next match in forward.N
For previous match in backward.Backward Search
?
Search for a pattern which will take you to the previous occurrence.n
For next match in backward direction.N
For previous match in forward direction.Screen Navigation
CTRL+F
Forward one windowCTRL+B
Backward one window.CTRL+D
Forward half window.CTRL+U
Backward half window.Line Navigation
In case You want to locate particularerror
, you may want to navigate line by
line using these keys:j
Navigate forward by one line.k
Navigate backward by one line.Count Navigation
10j
10 lines forward.10k
10 lines backward.CTRL+G
Shows the current file name along with line, byte and percentage statistics.Other Navigation
G
Go to the end of file.g
Go to the start of file.q
or ZZ
ExitF
Simulate tail -f.
Post a Comment
Post a Comment