Environment: RedHat Linux Enterprise 6+virtual Box 4.1
Anyone who has used a DOS command should know that we can use the type command to view the contents of a file. There are five related commands under Linux that have different functions, but they are all like the type command and can only be used to view text files.
1.cat command
The cat command is most like the type command, and the method used is simple: "Cat file name." More powerful than the type command, however, is that it can view multiple files at the same time: "Cat file name is two".
2. More Commands
The more command can be used not only for paging (cat List.txt | more), but also for direct use to view file information (more list.txt).
If the text file is longer and one screen cannot be displayed, then using the Cat command may not be possible to see. Here we can simply use more to replace the Cat command. The effect is similar to the type file name/p. Use the more command to display one screen of text at a time, display full, stop, and prompt for the percentage of all content displayed, press the SPACEBAR to see the next screen.
3.less command
The less command functions almost as much as the more command, and it also shows the file by page, except that the less command allows the user to scroll forward and backward through the file while displaying the file.
Forward: Press the B key;
Turn backward: press P key;
Specify location: Enter a percentage
Exit: Q
4. Head command
The head command allows you to view only the first few lines of a file in the following format:
Head-Number of rows file name
If the number of rows is not specified, the default value of 10 is used.
5.tail command
Tail-line Number file name
corresponding to the head command, we can use the tail command to view the contents of the end of the file. Usually used for real-time
Monitors whether a file has been modified and is usually used to observe the log. Such as:
Tail-f Maillog