DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Managing files

Reading a file one screen at a time

The more command displays a file one screen at a time. If the file fits on one screen, more quits and you are returned to the prompt. If the file is more than one screen long, more displays a prompt at the bottom of the screen showing what percentage of the file you have already read. Press <Space> to see another screen of the file. (You can use <Enter> to see another line of the file.) To quit more without reading the whole file, type q.

The more command lets you search for words in a file by typing a slash (/). Type a ``/'', then type the word or words you want to search for at the / prompt at the bottom of the screen. more skips to the next page of the file where those words occur. more can only search forward; if the words you are searching for come before where you currently are in the file, more cannot find them.

Try reading through the file /etc/passwd (a file that stores a variety of information about users on the system) to find your login name:

  1. Type more /etc/passwd and press <Enter>. The first screen of the file will be displayed.

  2. Type /, then type your login name at the / prompt at the bottom of the screen and press <Enter>.

  3. more skips to the page where it finds your login name. (This does not work if you have already seen your login name on the screen because more cannot search backward.)

  4. If you still see a More prompt at the bottom of the screen, press q to quit more.

Q: more seems much better than cat; is there any reason I should use cat instead?

A: cat can be better than more in some instances. If you want to look at a short file, cat is probably better because it does not waste time loading the file into a buffer and then paging it out on the screen. Also, cat is more forgiving about what it displays. more cannot display files containing control characters (it gives you the error message Not a text file), whereas cat tries its best to display any file.


Next topic: Reading just the first or last lines of a file
Previous topic: More ways to look at files

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003