To view the file Contents command:
More and less
Use the cat command to view the file. Sometimes files are too large to be used with pipe symbols | With more or less.
Cat < text file name >|more
Cat < text file name >|less
Less is the stronger version of more. More does not support forward flipping, less support. For more details, see the more and less documentation.
F: Turn backwards
B: Flip Forward
↑: Flip up one line
↓: Like the next turn of the line
PageUp: Page forward.
PageDown: Page backward.
N: The value n lines forward N.
。 : Last page.
,: Start one page.
pr
The PR command can handle the format of output produced by other commands, using the following:
PR < optional > [< file name;]
This command causes < file name > the file represented by the specified format to be output at standard output, and if < file name > is omitted, the input is obtained through the pipeline, and the commonly used options are:
+< page number: From the page that specifies the page number, the default page number is 1.
-< number of columns;: Specifies the number of columns at the time of output, default is 1.
-W: The number of characters per line, the default is 72.
-L: The number of rows per page, default is 66.
-h < string;: Use the specified string instead of the file name as the header.
For more detailed commands, refer to the PR man document.
Head and tail
The cat command outputs the entire text content, but sometimes we just care about the content of some parts of the text, and you can use the tail and head commands to implement partial output.
The tail command can output the last part of a text file using:
tail [-< number;] < file name >
< number > Indicates the number of rows to output, with a default value of 10. For example:
TAIL–20 ABC
Indicates that the last 20 lines of the file ABC are displayed on the screen.
The head command outputs the beginning part of the text file, using the following:
Head [-< number;] < file name >
< number > also indicates the number of rows to output, the default value is 10. For example:
HEAD-20 ABC
Outputs the first 20 lines of the file ABC on the screen.
For example, combine the first 30 rows of the A1.txt file under the current directory with the 25 lines at the end of the A2.txt file to form a new text file, ABC.
Method One:
HEAD-30 a1.txt > ABC
TAIL-25 a2.txt >> ABC
The ">>" symbol here is also the output redirect, and the difference between ">" is that it adds the output to the existing contents of the ABC file without deleting the original content.
Method Two:
Head-30 A1.txt > ABC1
tail-25 a2.txt > ABC2
Cat ABC1 ABC2 > ABC
RM ABC1 ABC2
Another common usage of tail is to view the log files using the "-F" parameter.
Tail–f < log file name >
This command is used to view the content appended to the specified log file.
For more detailed commands, refer to the tail man document.
WC
The WC command can count the number of lines of text, the number of words, and the total number of characters in a file (or standard input), using:
WC < file name >
Linux3 Some file operation commands MORE,LESS,PR,HEAD,TAIL,WC