< Using the less command >
less
is a program that lets you view text files, like cat
does, but if the files are so long that they don't fit on your screen, less
automatically paginates the file. You use less
by giving the file name as an argument to it:
$ less view_this
When viewing the file, you can use Page Up and Page Down keys to move through the file, and typing q
will exit.
You can also open several files at the same time so you can navigate from one file to next without closing it first. If you want to open several files, just give all the file names at once:
$ less file1 file2 file3
When viewing several files at the same time, you can use :n
for examining the next file and :p
for the previous file.
Here are some, but absolutely not all, of the commands you can use in less
:
Command / key |
Action |
e, j, Down, or Enter |
move forward one line |
y, k, or Up |
move backward one line |
f, Space, or Page Down |
move forward one page |
b, or Page Up |
move backward one page |
/characters |
search forward in the file for lines containing the specified characters |
n |
repeat the previous search |
:e file_name |
examine a new file |
:n |
examine the next file |
:p |
examine the previous file |
h, or ? |
display help |
q |
quit |