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 mainly explains the "Linux comm command use case analysis", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "Linux comm command use case analysis" bar!
How to use comm to compare two sorted files
To compare two sorted files using the comm command, simply take their names as arguments to the comm command. Here is the usual syntax:
Comm [name-of-first-file] [name-of-second-file]
For example, suppose file1 and file2 are two files in this case. The former contains the following lines:
001056127258
The latter contains the following lines:
002056167369
At this point, the output of the comm command is shown in the following figure:
Comm file1 file2
As you can see, the output contains three columns. The first column is the content contained only in the file1, the second column is the content contained only in the file2, and the third column is the content contained in both files.
How not to output some columns in the comm command output
You don't have to output some columns in the comm command output if you want. For this feature, you have three command line options available:-1,-2, and-3. As you might have guessed, these numbers represent columns that you do not want to output.
For example, the following command will not print the third column in the above example:
Comm-3 file1 file2
So, as you can see, the third column has no output.
Note that you can use a single command without printing multiple columns at the same time. For example:
Comm-12 file1 file2
The above command will not output the first and second columns.
How to use the comm command to compare two unsorted files
As we know, comm can only be used for sorted files. If one of the files is found to be unsorted, a message is generated in the output to tell the user. For example, we swap the first and second lines of file1 and compare them with file2. The following is the output of the command:
As you can see, this command produces an output that tells us that file1 is not sorted yet. At this point, if you don't want the tool to check whether the input has been sorted, you can use the-nocheck-order option:
Comm-nocheck-order file1 file2
You can see that the previous prompt has disappeared.
Note that if you want to explicitly tell the comm command to check that the input files are sorted, you can use the-check-order option.
How to separate the output column of a comm command with a custom string
By default, the output columns of the comm command are separated by spaces. However, if you want to use a custom string as a delimiter, you can use the-output-delimiter option. When using this option, you need to specify the string you want to use as the delimiter.
Comm-output-delimiter=+ file1 file2
For example, we use the plus sign as the delimiter:
How to make the output line of comm terminate with NUL character
By default, the output line of the comm command terminates with a new line. However, if you want, you can terminate with the NUL character instead, just use the-z option:
Comm-z file1 file2 thank you for your reading, the above is the "Linux comm command use case analysis" content, after the study of this article, I believe you have a deeper understanding of the use of Linux comm command example analysis of this problem, the specific use also needs to be verified by practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.