This post was originally published, in a slightly different form, at Opensource.com and appears here via a Creative Commons Attribution-Share Alike 4.0 International License.
There are a number of utilities that enable you to view text files when you’re at the command line. One of those utilities is more.
more is similar to another tool called less. The main difference between them is that more only allows you to move forward in a file.
While that may seem limiting, it has some features that are worth knowing about. Let’s take a quick look at some of what more can do and how to use it.
Let’s say you have a text file and want to read it at the command line. Just open the terminal, pop into the directory that contains the file, and type this command:
For example, more jekyll-article.md.
Press the space bar on your keyboard to move through the file or press q to quit.
To search for some text in the file, press the / key followed by the word or term you want to find. For example, to find the phrase terminal, type:
Search is case sensitive. Typing Terminal isn’t the same as typing terminal.
Using More with Other Utilities
(You might think what comes next is a so-called useless use or abuse of some commands. But you know what? I don’t care.)
You can pipe text from other command line utilities into more. Why do that? Because sometimes the text that those tools spew out spans more than one page.
To do that, type the command and any options, followed by the pipe symbol (|), followed by more. For example, let’s say you have a directory that has a large number of files in it. You can use more with the ls command to get a full view of the contents of the directory:
ls | more
You can also use more with the grep command to find text in multiple files. In this example, I use grep to find the text productivity in multiple files for my articles:
grep ‘productivity’ *.md | more
Another utility you can combine with more is ps (which lists processes that are running on your system). Again, this comes in handy when there are a large number of processes running on your system and you need a view of all of them — for example, to find one that you need to kill. To do that, use this command:
ps -u scott | more
Replace scott with your user name.
As I mentioned at the beginning of this post, more is easy to use. It’s definitely not as flexible as its cousin less, but it can be useful to know.