In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article analyzes with you "Linux system cat command use method is what". The content is detailed and easy to understand. Friends interested in "what is the use method of cat command in Linux system" can read it slowly and deeply along with the idea of Xiaobian. I hope it can help everyone after reading. Next, follow the small series to learn more about "what is the use of the cat command in Linux system".
cat is a tool used to view text files and connections in Linux systems, and its main function is to view file contents.
cat help can view cat help information, such as the use of various parameters, of course, you can also use man cat to view, it is recommended that you develop a command do not understand the usage, use-help or man to view help information, develop good habits. filename is the file name, that is, the name of the file you need to view in the system. Similar commands to this command include: tac, less, tail, more
Parameter Description: -A: - show-all is equivalent to-vET-b: -number-nonblank Output line numbers for non-empty output, i.e., display the row number before each line-e: equivalent to-vE-E: -show-ends Display $-n: -number Output line numbers at the end of each line, i.e., display the row number before each line-s: -squeeze-blank No output of multiple empty lines-t: equivalent to-vT-T: -show-tabs Display skip characters as ^I-u:(ignored)-v: - show-nonprinting Use ^and M-references, except LFD and TAB-help Show this help message and leave
Use example: (In the following example, linuxyw.txt is the file name) cat linuxyw.txt View the contents of the file name linuxyw.txt, as shown in the following figure, the default is three lines:
-A with parameter demonstration: (-show-all equivalent to-vET), rarely used cat -A linuxyw.txt
-b Output line number for non-empty lines:cat -b linuxyw.txt
-e is equivalent to-vE (-show-ends shows $at the end of each line), cat -e linuxyw.txt is rarely used
-n Show row numbers for all rows cat -n linuxyw.txt
-s-squeeze-blank does not output multiple blank lines, in fact, when multiple lines of spaces are together, only one line of spaces is output. Not commonly used, other parameters do not demonstrate, can operate on their own, conducive to their own learning.
- help(later for do not understand the command or software installation, you can use help to get help)
cat Example of creating a file or connection file: To create a file with cat, you need to end it with EOF (not necessarily EOF, recommended for beginners) If you create a file manually with cat, you need to press Ctrl+D at the end. As shown in the figure:
After typing www.linuxyw.com, press Ctrl+D to end the input, so that the file is created. The contents of the file are the two lines of i love linuxyw.com and www.linuxyw.com:
When using cat > linuxyw.com, use the> symbol, this symbol is the meaning of redirection, will overwrite the contents of the original file, no file will be automatically created. If you use the>> symbol, that is, add content to the table, it will not overwrite the original file content, only the content you entered will be appended to the original file content.> Don't mix it up, it can be a big problem.
If you don't use manual, you can use EOF symbol, as shown in the figure: When the first line is used and>>, as in the above example
If you are a beginner, the following content does not understand, you can skip first, and then come back later. If you need to generate a configuration file when writing a shell script, but the configuration file has variables, you need to enclose EOF in single quotes, otherwise the variables will be parsed. And when writing scripts, EOF cannot be followed by other symbols such as spaces, otherwise errors will occur. The following figure shows that when I write a script, I ask that the contents under cat be generated into the script configuration file without moving. If EOF is not enclosed in single quotes, the following variables such as ${VIP} will be parsed, resulting in an incorrect configuration file.
The following script is what I need to parse variables in cat when generating configuration files, so that I don't need to use single quotes.
Here's a simple example of how to do it: the shell script is written as follows: cat above generates the linux_cat1.txt file, cat below generates the linux_cat2.txt file.
After executing the script, we cat look at these two files.
cat Merges one or more files into a single file: e.g. merges the contents of file 1, file 2, and file 3 into file 4. As shown in the following example.
About Linux system cat command use method is what to share here, I hope the above content can let everyone improve. If you want to learn more, please pay more attention to the updates of Xiaobian. Thank you for your attention to the website!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.