|
|
Sometimes it is useful to see just the first few, or last few, lines in a file. If you want to see what is in a file without looking at the whole file, you may find the head command useful. The tail command, which looks at the last few lines, can be useful as well. For example, you could use tail to look at the latest information in a log file, a file that is being constantly updated by some program on the system.
To look at the first few lines of a file, type head filename, where filename is the name of the file you want to look at, and then press <Enter>. By default, head shows you the first 10 lines of a file. You can change this by typing head -number filename, where number 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 the tail command. tail works the same way as head: type tail and the filename to see the last 10 lines of that file, or type tail -number filename to see the last number lines of the file.
Try using tail to look at the last five lines of your .profile or .login:
% tail -5 $HOME/.login
setenv TERMCAP $term[2] # terminal data base
endif
unset term noglob
setenv PRINTER tpubs_lw1
setenv WPVER lyrix6 # default lyrix version