Command Line Basics: View Text Files with more

One of the things you may find you want to do often from your command line is to view the contents of a text file. This could be to view the contents of some startup script or just one of your own basic configuration files like .bashrc or .bash_aliases. The command is simple to use. Just type more followed by the file name. Here’s an example (assuming you have X installed).

more /usr/lib/X11/config/xorg.cf

You should now see the first screenfull of text in the file displayed on your terminal. To see more of the file, just hit the spacebar, and more will show you the next screenfull of text. You can also move back up the file by pressing the [B] key. (This trick only works when viewing files, it doesn’t work on piplined input.) When you’ve seen enough, you can get back to your command line prompt by pressing the [Q] key.

Pipelining Command Output to more

Another way to use more is when you have a large amount of text output from a command that exceeds the size of your terminal window. Say you want to view the directory listing of a large directory like /etc. This directory can contain a lot of files and require you to scroll up to see the beginning of a listing. No big deal if you’re in a graphical log-in session. But what if you’re on a terminal log-in session? There is no scroll bar. more to the rescue!

ls -l /etc | more

As you can see, more can be a handy tool to have in your ever expanding command line arsenal.

But wait, there’s less!

You read that correctly. There’s an improved text viewing utility that expands upon the functionality provided by more; the ironically named less. I’ll cover that one in another post.

3 thoughts on “Command Line Basics: View Text Files with more

    1. Linerd Post author

      Max – Thanks for the comment. I didn’t know that about the cacheing. I’m only familiar with the differences in how more and less behave for the user.

      Reply
  1. Pingback: fsdaily.com

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.