Using more to view text files at the Linux command line

Text files and Linux go hand in hand. Or so it seems. But how you view those text files depends on what tools you're comfortable with.
137 readers like this.

There are a number of utilities that enable you to view text files when you're at the command line. One of them is more.

more is similar to another tool I wrote about called less. The main difference is that more only allows you to move forward in a file.

While that may seem limiting, it has some useful features that are good to know about. Let's take a quick look at what more can do and how to use it.

The basics

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:

more <filename>

For example, more jekyll-article.md.

Viewing a file with more

Press the Spacebar on your keyboard to move through the file or press q to quit.

If you want 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:

/terminal

Searching in more

Search is case-sensitive. Typing Terminal isn't the same as typing terminal.

Using more with other utilities

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

Using the ls command with 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 source files for my articles:

**grep ‘productivity’ *.md | more**

Using the grep command with 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

Note that you'd replace scott with your username.

Using the ps command with more

As I mentioned at the beginning of this article, more is easy to use. It's definitely not as flexible as its cousin less, but it can be useful to know.

That idiot Scott Nesbitt ...
I'm a long-time user of free/open source software, and write various things for both fun and profit. I don't take myself all that seriously and I do all of my own stunts.

3 Comments

You didn't say why you might ever need to use more instead of less. more came first and less' name was a play on words because less does more than more. You never need more because it does less than less. You don't need it just because it is there.

I have used OSTechNix in the past, but as I used it today to find useful documentation about more, less, and most, I found a number of other very useful resources as well. Based on my background and experience, I find the information both accurate and a good place to remember additional tidbits and nuances that are easily forgotten or left behind. Excellent supplementary reference site.

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.