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
3
votes
1 answer

BASH: comm (or similar) when compare multiple files

I've the following problem: I would like to compare the content of 8 files contaning a list like this Sample1.txt Sample2.txt Sample3.txt apple pineapple apple pineapple apple pineapple bananas bananas …
fabioln79
  • 395
  • 2
  • 5
  • 16
2
votes
4 answers

bash: Difference between join and comm

# comm -12 /tmp/src /tmp/txt | wc -l 10338 # join /tmp/src /tmp/txt | wc -l 10355 Both the files are single columns of alphanumeric strings and sort-ed. Shouldn't they be the same? Updated following @Kevin-s answer below: cat /tmp/txt | sed…
Tathagata
  • 1,955
  • 4
  • 23
  • 39
2
votes
1 answer

Windows command to print only common lines in two or more files

Something like comm but for Windows (No, installing Cygwin just for this is not a good idea.) It will be great if it will allow compare more than 2 files at once. Example for 2 files: File1: foo1 foo2 foo3 bar File2: bar foo2 Output: foo2 bar (or…
Pol
  • 5,064
  • 4
  • 32
  • 51
2
votes
3 answers

How can I append values to each line in file1 after using part of that line to index into file2 and lookup the value?

I basically have the following 2 files: $ cat file1.txt AB,12 34 56,2.4,256,, CD,23 45 67,10.8,257,, EF,34 56 78,0.6,258,, GH,45 67 89,58.3,259,, ... $ cat file2.txt AB,12 34 56,2.4,36 XY,56 99 11,3.6,15 ZQ,12 36 89,5.9,0 EF,34 56 78,0.6,99 GH,45…
Marc Ryan
  • 23
  • 2
2
votes
2 answers

Bash script creating new folders from a list stored in a variable

I am trying to write a bash script that creates new folders with the same name and structure as the directories on my server. first I got all directories and sorted them by name: allDirLocal=$(cd $dirLocal ; find -type d |sort) …
Bunny
  • 23
  • 3
2
votes
2 answers

Find unique lines between two files

I have two very large files (File 1 and File 2), File 1 has many rows and columns, I am pasting column 1 for sake of simplicity. I want to print only those lines which are unique to File 1. File…
Waqas Khokhar
  • 159
  • 1
  • 11
2
votes
5 answers

Remove blank spaces comm output

I have two lists of IDs that I am comparing with comm command. My problem is that output looks like this: YAL002W YAL003W YAL004W YAL005C YAL008W YAL011W All I want to do is try to pipe it somehow so the file…
Juan LB
  • 31
  • 5
2
votes
2 answers

How to get the output from the comm command into 3 separate files?

The question Unix command to find lines common in two files has an answer suggesting the use of the comm command to do the task: comm -12 1.sorted.txt 2.sorted.txt This shows the lines common to the two files (the -1 suppresses the lines that are…
Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
2
votes
1 answer

comm command gives faulty output?

I have two files which just list a bunch of different file names on each line. I merged them, sorted them, and then checked the comm output and noticed something really interesting. $ sort -u -o list1 list1 $ sort -u -o list2 list2 $ cat list1 list2…
zli
  • 307
  • 1
  • 12
2
votes
2 answers

BASH comm command, but for multiple columns

I am looking for something similar to the bash command comm, that I can use to select entries both unique to my 2 files and common to them. Comm worked great when I had just one column per file, eg. comm -13 FILE1.txt FILE2.txt >…
Yano
  • 27
  • 6
2
votes
2 answers

Unix Compare Two CSV files using comm

I have two CSV files. 1.csv files has 718 entries and 2.csv has 68000 entries. #cat 1.csv #Num #Name 1 BoB 2 Jack 3 John 4 Hawk 5 Scot ........... #cat 2.csv #Num #Name 1 BoB 2 John 3 Linda 4 Hawk 5 …
Arun
  • 1,160
  • 3
  • 17
  • 33
2
votes
1 answer

Subset rows of file 2 based on common values of single column in file 1 UNIX

I'm dealing with large files where I would like to extract only the rows where the values of one column are contained in the values of a column of another file. For example, in file1 I have 10,000 rows that look something like this: Chr13998356 T …
user2903950
  • 65
  • 1
  • 2
  • 7
2
votes
3 answers

Comparing many files in Bash

I'm trying to automate a task at work that I normally do by hand, that is taking database output from the permissions of multiple users and comparing them to see what they have in common. I have a script right now that uses comm and paste, but it's…
freehunter
  • 144
  • 1
  • 9
1
vote
1 answer

linux comm produces different results when run from crontab

I am running the following command from a bash script: comm -23 file1 file2 > file3 (file1 & file2 are de-duped and sorted first) This produces a file3 that contains rows unique to file1 only (what I want). When the script is run from the command…
Ben
  • 69
  • 1
  • 9
1
vote
0 answers

Identifying matching lines across multiple files in Linux

I'm working on a script to help me identify matching lines across multiple files. I've had luck with the comm command: comm -12 <(sort file1.txt) <(sort file2.txt) This works and can be daisy-chained to expand to X number of files. My problem is…
Yusif_Nurizade
  • 133
  • 1
  • 12
1
2
3
9 10