DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Working with files and directories

Looking at the contents of a file

The simplest way to look at the contents of a short file is to use the cat(C) command, as follows:

cat filename

If the file is more than one screen long, it scrolls off the screen, making it difficult to read its contents. If this happens, press <Ctrl>S to temporarily stop the scrolling, and <Ctrl>Q to restart the scrolling. If you want to stop the scrolling completely, press <Del>.

If you do not know what is in a file you want to look at, use the cat -v option, as follows:

cat -v filename

This option causes any unprintable characters in filename to be displayed in a manner which does not garble your screen. If you do use cat without using the -v option, and your screen becomes garbled and the machine beeps a lot, press <Ctrl><Del>, <Break>, or <Del> (depending on your terminal). If you cannot clear it, you may need to ask your system administrator for help.

To look at the contents of a file that is too big to fit on a single screen, use the more command, as follows:

more filename

You can use the pg command in the same way.

You can look at more than one file at a time by using the display commands with several filenames as arguments, as follows:

   $ more file4 file5 file6
In the case of the more command, press <Space> to display a screenful of text. When you reach the end of the first file, more displays a message at the bottom of the screen (Next file: filename2). Press <Space> again to go to the next file.

If you want to go directly to the next file before finishing the first, enter :n; more skips to the next file. See ``Listing the contents of a directory'' for more information on the more and pg commands.


Next topic: Finding out how much text is in a file
Previous topic: Finding out what type of data a file contains

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