Download Red Hat Linux 9 Red Hat Linux Getting Started Guide
Transcript
Chapter 13. Shell Prompt Basics 101 Figure 13-10. Piping Output of ls to more To search the output of a text file using more, press [/] and then type the keyword you want to search for within the file. For example: /foo Use the [Spacebar] to move forward through the pages. Press [q] to exit. 13.11. More Commands for Reading Text Files You have already been introduced to several basic shell prompt commands for reading files in text editors. Here are a few more. 13.11.1. The head Command You can use the head command to look at the beginning of a file. The command is: head filename head can be a useful command, but because it is limited to the first several lines, you will not see how long the file actually is. 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 as shown in the following command: head -20 filename 13.11.2. 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 10 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 print new messages from an open file to the screen in real-time. For example, to actively watch /var/log/messages, type the following at a shell prompt as the root user: tail -f /var/log/messages