The main drawback of the cat command is that you can’t control what’s happening after you start it. To solve that problem, developers created the “more” command. The more command displays a text file but stops after it displays each page of data.
more is a filter that displays the contents of a text file on the terminal, one screenful at a time. It normally pauses after each screenful, and prints —More— at the bottom of the screen.
$ more filename
The
--More--(n%)
message appears at the bottom of each screen, where n% is the percentage of the file that has been displayed. When the entire file has been displayed, the shell prompt appears.
When the –More–(n%)prompt appears at the bottom of the screen, you can use the keys described in the table to scroll through the file.
Keyboard Command | Action |
---|---|
Space bar | Moves forward one screen |
Return | Scrolls one line at a time |
b | Moves back one screen |
h | Displays a help menu of features |
/string | Searches forward for pattern |
n | Finds the next occurrence of pattern |
q | Quits and returns to the shell prompt |
more Command Examples
1. To browse the file:
# more file.txt
2. To display the prompt for continue:
# more -d file.txt
3. To stop pausing when ^L (form feed) appears:
# more -l file.txt
4. To specify “more” to count logically:
# more -f file.txt
5. To not to scroll, instead clear screen and then display:
# more -p file.txt
6. To not to scroll, instead print screen from top and then display:
# more -c file.txt
7. To sqeeze multiple blank lines into one:
# more -s file.txt
8. To suppress underlining:
# more -u file.txt
9. To search for a string and then display:
# more +/sa file.txt
10. Display the number of lines per screenful. The number argument is a positive decimal integer:
# more -n --lines 10 file.txt
10. To start displaying file from specified line number:
# more +10 file.txt