|
Sometimes it is useful to see just the first few, or lastfew, lines in a file. If you want to see what is in a filewithout looking at the whole file, you may find thehead command useful. The tail command,which looks at the last few lines, can be useful as well.For example, you could use tailto look at the latest information in a log file, a filethat is being constantly updated by some program on thesystem.
To look at the first few lines of a file, typehead filename, where filenameis the name of the file you want to look at, and then press<Enter>. By default, head shows you the first 10lines of a file. You can change this by typing head-number filename, wherenumber is the number of lines you want to see.
For example, if you want to see the first 15 lines of/etc/passwd, you could type:
head -15 /etc/passwd
To look at the last few lines of a file, use thetail command. tail works the same wayas head: type tail and the filename tosee the last 10 lines of that file, or typetail -number filename to see the lastnumber lines of the file.
Try using tail to look at the last five lines ofyour .profile or .login:
- Type tail -5 $HOME/.profile and press <Enter>.
(C shell users: type tail -5 $HOME/.login and press <Enter>.) - tail displays the last five lines of your .profile(or .login).
%
tail -5 $HOME/.login
setenv TERMCAP $term[2] # terminal data baseendifunset term noglobsetenv PRINTER tpubs_lw1setenv WPVER lyrix6 # default lyrix version
Previous topic: Reading a file one screen at a time
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003