Hi all,
I have got a problem while comparing 2 text files and the result should contains the unique values(Non repeatable).
For eg:
file1.txt
1
2
3
4
file2.txt
2
3
So after comaping the above 2 files I should get only 1 and 4 as the output. Pls help me out. (7 Replies)
Hi all,
I have a huge csv file with the following format of data,
Num SNPs, 549997
Total SNPs,555352
Num Samples, 157
SNP, SampleID, Allele1, Allele2
A001,AB1,A,A
A002,AB1,A,A
A003,AB1,A,A
...
...
...
I would like to write out a list of unique SNP (column 1). Could you... (3 Replies)
Hi All,
Is there a way to get NON unique lines from 2 or more concatenated files?
Basically I have several files which are very similar with the exception of few lines and I want to find out which lines are different in each file. Very simple example is
file1 contains:
1
2
3
4
5file2... (122 Replies)
Hi All,
I have a very huge file (4GB) which has duplicate lines. I want to delete duplicate lines leaving unique lines. Sort, uniq, awk '!x++' are not working as its running out of buffer space.
I dont know if this works : I want to read each line of the File in a For Loop, and want to... (16 Replies)
Hi,
I would like to compare 2 files, and have a return code write to a file.
regardless of the files contents are the same the code should be writing to a file (if both files contents are same then return code 0).
A simple example will be great :)
Thanks (3 Replies)
hi
i have used comm -13 <(sort 1.txt) <(sort 2.txt) option to get the unique lines that are present in file 2 but not in file 1. but some how i am getting the entire file 2. i would expect few but not all uncommon lines fro my dat. is there anything wrong with the way i used the command?
my... (1 Reply)
hi
my problem is little complicated one. i have 2 files which appear like this
file 1
abbsss:aa:22:34:as akl abc 1234
mkilll:as:ss:23:qs asc abc 0987
mlopii:cd:wq:24:as asd abc 7866
file2
lkoaa:as:24:32:sa alk abc 3245
lkmo:as:34:43:qs qsa abc 0987
kloia:ds:45:56:sa acq abc 7805
i... (5 Replies)
Hello I'm having a little difficulty in writing a shell script for a few simple tasks.
First I have two files "file1.txt" and "file2.txt" and I want to read and compare the last line of each file. The files look like this.
File1.txt
File2.txt
After comparing the two lines I would... (2 Replies)
Hello Everyone!
I have updated the first post so that my intentions are easier to understand, and also attached sample files (post #18).
I have over 500 text files in a directory. Over 1 GB of data. The data in those files is organised in lines:
My intention is to return one line per... (23 Replies)
Hi,
I am trying to script the below, but I am not very good at it :(
Your help would be greatly appreciated.
1. read all files in the directory in strings
strings *.*
2. in each file, for each line that contains "ABCD", store characters located at position 521 and 522 of this line... (9 Replies)
Discussion started by: clippertm
9 Replies
LEARN ABOUT OSF1
comm
comm(1) General Commands Manual comm(1)NAME
comm - Compares two sorted files.
SYNOPSIS
comm [-123] file1 file2
STANDARDS
Interfaces documented on this reference page conform to industry standards as follows:
command: XCU5.0
Refer to the standards(5) reference page for more information about industry standards and associated tags.
OPTIONS
Suppresses output of the first column (lines in file1 only). Suppresses output of the second column (lines in file2 only). Suppresses
output of the third column (lines common to file1 and file2).
The command comm -123 produces no output.
OPERANDS
A pathname of the first file to be compared. If file1 is a hyphen (-), the standard input is used. A pathname of the second file to be
compared. If file2 is a hyphen (-), the standard input is used.
If both file1 and file2 refer to standard input or to the same FIFO special, block special or character special file, the results are unde-
fined.
DESCRIPTION
The comm command reads file1 and file2 and writes three columns to standard output, showing which lines are common to the files and which
are unique to each.
The leftmost column of standard output includes lines that are in file1 only. The middle column includes lines that are in file2 only.
The rightmost column includes lines that are in both file1 and file2.
If you specify a hyphen (-) in place of one of the file names, comm reads standard input.
Generally, file1 and file2 should be sorted according to the collating sequence specified by the LC_COLLATE environment variable. (See
sort(1).) If the input files are not sorted properly, the output of comm might not be useful.
EXIT STATUS
Successful completion. Error occurred.
EXAMPLES
In the following examples, file1 contains the following sorted list of North American cities:
Anaheim Baltimore Boston Chicago Cleveland Dallas Detroit Kansas City Milwaukee Minneapolis New York Oakland Seattle Toronto
The second file, file2, contains this sorted list:
Atlanta Chicago Cincinnati Houston Los Angeles Montreal New York Philadelphia Pittsburgh San Diego San Francisco St. Louis
To display the lines unique to each file and common to the two files, enter: comm file1 file2
This command results in the following output: Anaheim Atlanta Baltimore Boston Chicago Cincinnati Cleveland Dal-
las Detroit Houston Kansas City Los Angeles Milwaukee Minneapolis Montreal New York Oakland Philadel-
phia Pittsburgh San Diego San Francisco Seattle St. Louis Toronto
The leftmost column contains lines in file1 only, the middle column contains lines in file2 only, and the rightmost column contains
lines common to both files. To display any one or two of the three output columns, include the appropriate flags to suppress the
columns you do not want. For example, the following command displays columns 1 and 2 only: comm -3 file1 file2
Anaheim
Atlanta Baltimore Boston
Cincinnati Cleveland Dallas Detroit
Houston Kansas City
Los Angeles Milwaukee Minneapolis
Montreal Oakland
Philadelphia
Pittsburgh
San Diego
San Francisco Seattle
St. Louis Toronto
The following command displays output from only the second column: comm -13 file1 file2
Atlanta Cincinnati Houston Los Angeles Montreal Philadelphia Pittsburgh San Diego San Francisco St. Louis
The following command displays output from only the third column: comm -12 file1 file2
Chicago New York
SEE ALSO
Commands: cmp(1), diff(1), sdiff(1), sort(1), uniq(1)comm(1)