less notes

May 06, 2015

unix
linux
bash
howto

less command.

The keys in less are similar to Vim:

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

To navigate in large files

CTRL+F – forward one window
CTRL+B – backward one window
CTRL+D – forward half window
CTRL+U – backward half window
j – navigate forward by one line
k – navigate backward by one line
G – go to the end of file
g – go to the start of file
q or ZZ – exit the less pager

Other useful options

v – using the configured editor edit the current file.
h – summary of less commands
&pattern – display only the matching lines, not all.

File paging

You can open multiple files passing the file names as arguments:

$ less file1 file2

Written by huckbit web developer who lives and works in UK building cool things. You can find me on twitter.