The head Command
head <filename>
By default, you can only read the first ten lines of a file.You can change the
number of lines displayed by specifying a number option.
head -20 <filename>
The tail Command
The reverse of head is tail. Using tail, you can view the last ten lines of a file. This can be useful for viewing the last ten lines of a log file for important system messages. You can also use tail to watch log files as they are updated. Using the -f option, tail automatically prints new messages from an open file to the screen in real-time. For example, to actively watch /var/log/messages, enter the folowing at a shell prompt (as the root user):
tail -f /var/log/messages
Press[Ctrl]-[C] when you are finished.
Viewing Files with less
The format of the less command is:
less <filename>
The main difference between more and less is that less allows backward and single-line movement using the same navigation as man pages: press the [Space] bar to go down one page, the [B] to go back one page, the directional (or "arrow") keys to move one line at a time, and [Q] to quit.To search the output of a text file using less, press [/] and enter the keyword to search for within the file.
/stuff
Comments
Post a Comment