If the output of a text file exceeds the terminal window you probably want to use the "more" or "less" 1
commands instead of cat. 2
Both tools are known as pagers and will take the input from a file and send it to the terminal one page 3
at a time. 4
Less extend the capabilities of more and is probably the most advanced and used reading tool that Linux 5
provides. To view the contents of a file with less 6
you write less and the name of the file using a correct path like say, less/var/log/dmesg 7
This is the contents of the file. 8
I've already discussed some rules and options when we've talked about man pages in the previous section 9
of the course. When you run man and a command to see its man page, less is launched by default. 10
For example man rm and the contents of the main page is displayed using less. Let's see 11
the most important and used options. Again while you are in a file, you can get additional 12
help by typing the letter h. 13
To exit the file type q. 14
I'm opening it again. 15
While in the file, you can use the arrow keys to move a line up or down. 16
To forward one window press on control and f or on the space key. 17
I'm moving one window forward. 18
And if you want to move backwards a screen or a window, you press control B. I'm moving backwards. 19
I'm already at the beginning of the file; to go to the very beginning of the file 20
typed lowercase g 21
while to go to the very end type uppercase G. I'm at the end. 22
Sometimes you want to search in the current file for a specific string. Let's say I want to search for 23
the root string in this file. 24
First, I'm going to the beginning of the file by pressing g. 25
I'm at the beginning and to search for the string, I write a / and the string I want to search for 26
root 27
I'm hitting enter. 28
Any matches in the current file will be highlighted. 29
You can then navigate between matches with n which means next occurrence 30
next, next or shift n or uppercase N , which means the previous occurrence. 31
So it searches backwards. 32
I'm pressing capital N. 33
This is the first occurrence; when you search by using a slash and the search term 34
it searches forward 35
but if you are for example, at the end of the file and want to search backwards, then you type a question 36
mark instead of a slash. 37
I'm going to the end of the file by pressing uppercase G. 38
And I'm searching for the word kernel backwards. 39
I'm hitting enter. 40
It has searched backwards for the kernel word and it found more matches; press on n and uppercase N to 41
go from match to match, 42
backwards and forward. 43
These were the most important options of less.