Using more to view text files at the Linux command line

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.

Terminal command prompt on orange background
Image credits : 
x

Subscribe now

Get the highlights in your inbox every week.

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.

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

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

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**

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.

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.

About the author

That idiot Scott Nesbitt ...
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. You can find me at these fine establishments on the web: GitLab, Open Source Musings, The Plain Text...