In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Linux system cat command how to use, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.
Cat command is a command used to view text contents in Linux system. Using cat, you can view file contents, create files, merge files, append file contents, and so on.
A: the main usage of viewing the contents of the file:
1. Cat f1.txt, view the contents of the f1.txt file.
2. Cat-n f1.txt, view the contents of the f1.txt file, and number all output lines starting with 1.
3, cat-b f1.txt, view the contents of the f1.txt file, the usage is similar to-n, except that the blank lines are not numbered.
4. Cat-s f1.txt, when you encounter two or more blank lines in a row, replace them with blank lines on one line.
5. Cat-e f1.txt, with a $symbol after each line of the output.
6. Cat f1.txt f2.txt, displaying the contents of both f1.txt and f2.txt files, note that the file names are separated by spaces instead of commas.
7, cat-n f1.txt > f2.txt, add a line number to each line in the f1.txt file and then write it to the f2.txt, overwrite the original content, and create it if the file does not exist.
8, cat-n f1.txt > > f2.txt, add a line number to each line in the f1.txt file and then append it to the f2.txt, will not overwrite the original content, and create it if the file does not exist.
B: the use of creating a file and writing the contents of the file:
Note: when creating a file, set the end flag of the file, that is,
C: the usage of appending file contents:
Note: unlike creating the contents of the file, the symbol one-sided number > becomes a double-sided number > >.
D: usage of file merging
Write the contents of the file f2.txtref 3.txtref 4.txt to f1.txt, and if the f1.txt file previously has content, it clears them first and then writes the merged content.
If you do not want to clear the contents of the file, you can change the one-sided number > to the double-sided number > >, as shown in the following figure:
After reading the above, have you mastered how to use the cat command in the Linux system? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
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.