ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
hello
i use comm to compare two very simple file.
file1:
0
0
1
file2:
0
1
0
comm file1 file2 ---->output:
................0
0
................1
........0
I view comm's man page, the interpretation of output is listed following:
Column one contains lines unique to FILE1, column two contains lines unique to FILE2, and column three contains lines common to both files
But i do not understand how does the result generate above? it seems different from the man page gave. Anyone can tell me what's the rule of comm's comparison or give me a reference? Thank in advance
That's very weird. I used comm a couple of times and it worked fine for me. I suppose it's a bug and that happens when you have the same line more than one time in a file:
Sigh. If you read the man page for comm you might notice the words "compare two sorted files line by line". Note the word "sorted". The bug is in your use of comm, not in the code itself.
Originally posted by webeye First, thank you for zahadumy and eddiebaby1023 very much.
Second, I see that the two file must be sorted. but i don't understand what does the mean of "line by line"?
etc:
file1
0
1
file2
1
2
comm output
0
...................1
...........2
Who can describe the output of comparable process of simple example above?
It compares the file line by line, as you can see. On the first column you see lines which appear only in the first file, on the second column lines which appear only in the second file and on the third one lines common to both files. For more details:
The comm utility will read file1 and file2, which should be ordered in the current collating sequence, and produce three
text columns as output: lines only in file1; lines only in
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.