In the Linux system, many operations are operations on files in the system. "Everything is a file", and to debug the project deployed on the server, many are to edit the configuration file of the program. It would be embarrassing if you can't look up the contents of the text file proficiently.
1. cat command
The cat command is generally used to view plain text files (files with less content). The format of
"cat [选项][文件]"
cat is a very useful command. It is very friendly when used to view some text content whose length does not exceed the computer screen, but it is not suitable for View the contents of a very large file, because the file viewed with the cat command is too long, cat will keep refreshing along the beginning of the text.
2. The more command
The more command is used to view plain text files with a lot of text content. When the format is
more [选项][文件]
cat command to view a large file, the text content will scroll quickly under the screen, so that the content has already been turned over before the content can be seen clearly, and the more command, It will not automatically turn the page. The more command will display the content in the form of a percentage. You can manually turn the page through the space bar or the Enter key. Of course, you can only turn down.
3. head command
The head command is just like its English meaning. It is used to view the information of the first few lines of the file. We can use the head command to specify that only the data from the first line to the nth line is to be viewed. The format is
head [选项][文件]
4. tail command
The tail command is a very frequently used log for viewing the text at the end of the file. tail means tail. The tail command is often used in conjunction with the -f parameter to track log information.
5. tr command
The tr command can replace the character content in the text file. The format is
tr [原始字符][目标字符]
tr and is usually used in conjunction with the pipeline command. For example,
the tr command replaces all 1s in the text a.txt command with m, and all 3 in the n. Yes, the original content of the a.txt file is unchanged. If you want to update the content of the a.txt file, you can use output redirection >>.
6. wc command
wc command, listening to this name always reminds me of the word "cuckoo", but this command is used to count the number of lines, words and bytes of the text, the format is
wc [参数] 文本
parameter | effect |
---|---|
-l | Display the number of lines of text |
-w | Display text word count |
-c | Display the number of bytes |
You can use wc to act on a file directly, or you can use a pipe as the input of wc. When using a pipe, the output result of wc will not carry the file name.
7. stat command
The stat command can view the storage information and time information of a file. The file has three time states, namely: access, Modify, and Change. This time is the last access time of the file, the last permission change time of the file, and the last file. content change time
8. cut command
The cut command is used to extract text characters by column. The format is
cut [参数][文本]
The -d parameter can be specified as a delimited string, and the -f parameter specifies the data of which column to select
9. diff command
The diff command can be used to compare whether two files are the same, diff --brief can quickly assert whether two files are the same, and diff -c can show the different positions.