Questions tagged [comm]

Comm is a UNIX utility used to compare two sorted files line by line. (For COMM ports, use tag "serial-port")

137 questions
29
votes
3 answers

How to get the first column of comm output?

So I'm trying to get the first column of comm output using awk. I read that Tab was used as a separator for comm so I did: awk -F"\t" '{print $1}' comm-result.txt With comm-result.txt containing the output of: comm -3 file1 file2 But this doesn't…
Daddou
  • 379
  • 1
  • 4
  • 13
24
votes
3 answers

How to remove common lines between two files without sorting?

I have two files not sortered which have some lines in common. file1.txt Z B A H L file2.txt S L W Q A The way I'm using to remove common lines is the following: sort -u file1.txt > file1_sorted.txt sort -u file2.txt > file2_sorted.txt comm -23…
mllamazares
  • 7,876
  • 17
  • 61
  • 89
6
votes
2 answers

How to use "grep -f file" if "file" has null-delimited items?

I need to find null-delimited items from numerous files (data2, data3, ...) that are present in data1. Exact match is required. All works well with grep -f data1 data2 data3 ... until the items in data1 are also null-delimited. Using only newlines…
PesaThe
  • 7,259
  • 1
  • 19
  • 43
5
votes
1 answer

compare binary files and print only offset of matching line

For regular files I can use the comm command to find common lines. For example we have two files $ cat f1 line1 line2 line3 line4 line5 $ cat f2 line1 line20 line30 line4 line5 Its compared like: $ comm -12 f1 f2 line1 line4 line5 How to find…
webminal.org
  • 44,948
  • 37
  • 94
  • 125
4
votes
4 answers

Compare 2 similar files and only output the differences, preserving the order in which they occur?

hoping someone can help me get my head around this I have 2 files, one is 325 lines long, one is 361 lines long. The bulk of these files is identical content but the 2nd one has random extra lines inserted. I am only interested in the extra lines,…
user1108364
  • 41
  • 1
  • 2
4
votes
2 answers

Line number with comm command. Is it possible?

I compare two files with this command comm -13 file1 file2 It works perfectly and says me differences. But I would like to show me also the line number (lines unique in second file). file1: a d e f g file2: a b c d e I do: comm -13 file1…
defekas17
  • 155
  • 1
  • 9
4
votes
2 answers

Difference between two files without sorting

I have the files file1 and file2, where file2 is a subset of file1. That means, if I iterate over file1, there are some lines that are in file2, and some that aren't, but there is no line in file2 that is not in file1. There may be several lines…
Yanick Nedderhoff
  • 1,174
  • 3
  • 18
  • 35
3
votes
1 answer

Comparing two files based on 1st column, printing the unique part of one file

I have two files looking like this: file1: RYR2 29 70 0.376583106063 4.77084855376 MUC16 51 94 0.481067457376 3.9233164551 DCAF4L2 0 13 0.0691414496833 3.05307268261 USH2A 32 62 0.481792717087 2.81864194236 ZFHX4 14 37 0.371576262084 …
Miss
  • 35
  • 5
3
votes
4 answers

Finding common value across multiple files containing single column values

I have 100 text files containing single columns each. The files are like: file1.txt 10032 19873 18326 file2.txt 10032 19873 11254 file3.txt 15478 10032 11254 and so on. The size of each file is different. Kindly tell me how to find the numbers…
3
votes
3 answers

Comparing output from two greps

I have two C source files with lots of defines and I want to compare them to each other and filter out lines that do not match. The grep (grep NO_BCM_ include/soc/mcm/allenum.h | grep -v 56440) output of the first file may look like: ... ... # if…
stdcerr
  • 13,725
  • 25
  • 71
  • 128
3
votes
3 answers

Remove all lines in file A which contain the strings in file B

I have 2 text file and want remover lines in file A which contain the strings in file B file A: joe ball 1335 john dyer 1365 dylan fisher 1795 ian gill 1913 eric kelly 1101 file B: 1795 1913 And I want Bash code…
pedram
  • 35
  • 3
3
votes
4 answers

how to extract common lines across multiple file?

I have 15 different files that I want have a new file which include only common lines in all of them. for example: File1: id1 id2 id3 file2: id2 id3 id4 file3: id10 id2 id3 file4 id100 id45 id3 id2 I need the output be like: newfile: id2…
zara
  • 1,048
  • 3
  • 9
  • 19
3
votes
1 answer

Find lines common to several files

I'm trying to determine which header declares a specific function. I've used grep to find instances of the function's use; now, I want to find which header is included by all the files. I'm aware of the comm utility; however, it can only compare two…
Evan Kroske
  • 4,506
  • 12
  • 40
  • 59
3
votes
1 answer

Using grep to find difference between two big wordlists

I have one 78k lines .txt file with british words and a 5k lines .txt file with the most common british words. I want to sort out the most common words from the big list so that I have a new list with the not as common words. I managed solve my…
3
votes
5 answers

Finding Set Complement in Unix

Given this two files: $ cat A.txt $ cat B.txt 3 11 5 1 1 12 2 3 4 2 I want to find lines number that is in A "BUT NOT" in B. What's the unix command for it? I tried this but…
neversaint
  • 60,904
  • 137
  • 310
  • 477
1
2 3
9 10