Linux Command Line Tutorial
In this video, we will learn how to use less command. less is a command-line utility that displays the content of a file or a command output, one page at a time. The less command is mostly used for opening large files.
The general syntax for using less command is:
less [options] filename
It is also possible to use less with other commands output.
ls /etc | less
When opening a file that is too large to fit in one page, you will see the colon at the bottom of the screen. What makes less more appealing is its ease of file navigation.
Navigation Commands
Command | Output |
---|---|
f or space bar | next page |
j, down key or enter | next line |
k or up key | previous line |
b | previous page |
G | end of the file |
g | start of the file |
[n]G | goes to nth line |
/[pattern] | top-down search |
?[pattern] | bottom-up search |
n | next search result |
N | previous search result |
Options
Option | Effect |
---|---|
-N | show line numbers |
-X | preserve screen content after exiting less |
+F | watch out for changes being made to the file |
Thank you 🙂