Previous Table of Contents Next

Viewing a File

To view a file, type more filename and press Return. The file is displayed one screen at a time. Press the Spacebar to view the next screen.

To search for a specific string in a file you are viewing with more, type / search-string and press Return. The text scrolls to display the place in the file that contains the text you type as the search-string variable and displays the search string and the message . . . skipping at the top of the window. If there is no match, the message Pattern not found is displayed at the bottom of the window and the text does not scroll.

For example, to find the words Local aliases in the /etc/mail /aliases file, type /Local aliases and press Return:

/Local aliases

# Local aliases below #

NOTE:  You must use exact capitalization in the search string for the more command. If you type /local aliases in the previous example, the pattern is not found.

To search for the next occurrence of the search string, type n. To quit more, type q. The shell prompt is redisplayed.

Another way to quit more, if Control-C is set as your shell kill character, is to press Control-C. The shell prompt is redisplayed.

To display the shell intr character, type stty -a and press Return. A list of the stty settings is displayed. In this example, ^C is the shell intr character:

castle% stty -a
ispeed 88840 baud; ospeed 88824 baud;
rows = 36; columns = 113; ypixels = 478; xpixels = 801;
eucw 1:0:0:0, scrw 1:0:0:0
intr = ^c; quit = <undef>; erase = ^h; kill = ^u;
eof = ^d; eol = <undef>; eol2 = <undef>; swtch = <undef>;
start = ^q; stop = ^s; susp = ^z; dsusp = ^y;
rprnt = ^r; flush = ^o; werase = ^w; lnext = ^v;
-parenb parodd cs8 cstopb hupcl cread -clocal loblk crtscts crtsxoff
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl -iuclc
ixon -ixany ixoff -imaxbel
isig icanon -xcase echo echoe echok -echonl -noflsh
-tostop echoctl -echoprt echoke -defecho -flusho -pendin iexten
opost -olcuc onlcr -ocrnl -onocr -onlret -ofill -ofdel

Looking at the End of a File

To look at the end of a file, type tail filename and press Return. The last 10 lines of the file (by default) are displayed.

This example shows the tail of the /etc/lp/Systems file:

castle% /usr/bin/tail /etc/lp/Systems
#ident  "@(#)Systems    1.8     97/06/09 SMI"   /* SVr4.0 1.2   */
# This file previously contained an LP private interface.  It's
# contents are no longer used by the printing system and therefore
# obsolete.  Expect the file to be removed in a subsequent release
# of Solaris, along with the lpsystem(1M) command.
+:x:-:bsd:-:n:10:-:-:Allow all connections

By default, the head and tail commands display 10 lines. You can change the number of lines displayed by using the -n option. Substitute the number of lines you want to display for the letter n. For example, to display the last 20 lines of a file, type tail -20 filename and press Return.

NOTE:  tail shows a maximum of 4096 bytes (about 400 lines).

Looking at the Beginning of a File

To look at the beginning of a file, type head filename and press Return. The first 10 lines of the file are displayed.

This example shows the head of the /etc/passwd file:

castle% /usr/bin/head /etc/passwd
lp:x:71:8:Line Printer Admin:/usr/spool/lp:
smtp:x:0:0:Mail Daemon User:/:
uucp:x:5:5:uucp Admin:/usr/lib/uucp:
nuucp:x:9:9:uucp Admin:/var/spool/uucppublic:/usr/lib/uucp/uucico
listen:x:37:4:Network Admin:/usr/net/nls:

Previous Table of Contents Next