05-13-2008
This suggestion depends on how big your second file is.
But, you could try to put all the entries of the 2nd file into a grep list and then loop thru the 1st file only once. This way you avoid multiple loops that I suggested in my last post.
One more way would be to attack the i/p file in chunks of say 1000 lines, and append o/p to file3/4.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have to compare two text files, very few of the lines in these files will have some difference in some column.
The files size is in GB.
Sample lines are as below:
11111122222222333333aaaaaaaaaabbbbbbbbbccccccccdddddd
11111122222222333333aaaaaaaaaabbbbbbbbbccccccccddeddd
So assuming these... (19 Replies)
Discussion started by: net_shree
19 Replies
2. Shell Programming and Scripting
hi
I have 2 files to comapre ,in file a sible column it is numbers,in file b2 numbers and other values with coma separated.
i want compare numbers in file a with file b,and the out put put should be in C with numbers in both file a and b along with other columns of file b.
i used folowing... (7 Replies)
Discussion started by: satish.res
7 Replies
3. Shell Programming and Scripting
Hi All,
i've written script to collect the tablespaces and the datafiles related to each tablespaces with free space available and directed to two logfiles.. ( pasted below)
1. datafile_test.log
PSAPSR3
PSAPSR3700
PSAPSR3USR
2. freedata_test.log... (6 Replies)
Discussion started by: suri.tyson
6 Replies
4. Shell Programming and Scripting
I have two text files which have records of thousand rows. Each row is having around 40 columns. Each column is tab delimited. Each row is delimited by newline character.
My requirement is to find for each row i need to find whether any column is different between the two files. For each row i... (8 Replies)
Discussion started by: uihnybgte
8 Replies
5. Shell Programming and Scripting
Hi i have 2 csv files a.csv and b.csv with the same number of columns and a list of values in both of it. Each and every individual value in both the files need to compared and if it matches then print correct in a new csv file otherwise print Incorrect
eg
a.csv
1,12/27/2007,Reward,$10.00... (5 Replies)
Discussion started by: naveenn08
5 Replies
6. Shell Programming and Scripting
now i have a different file zoo.txt with content
123|zoo
234|natan
456|don
and file rick.txt with contents
123|dog|pie|pep
123|tail|see|newt
456|som|sin|sim
234|pay|rat|cat
i want to look for lines in file zoo.txt column1 that has same corresponding lines in column 1 of... (6 Replies)
Discussion started by: dealerso
6 Replies
7. Shell Programming and Scripting
Hello, I am trying to compare 2 files and get only the new lines as output. Note that new lines can be anywhere in the file and not necessarily at the bottom of the file.
I have made the following progress so far.
/home/aa>cat old.txt
0001 732 A
0002 732 C
0005 732 D... (7 Replies)
Discussion started by: cartrider
7 Replies
8. Shell Programming and Scripting
Dear All,
I would really appreciate if you can help me to resolve this file comparison
I have two files:
file1:
chr start end ID gene_name
chr1 2020 3030 1 test1
chr1 900 5000 2 test1
chr2 5000 8000 3 test2
chr3 6000 12000 4 test3
chr3 6000 15000 5 test3
file2:... (2 Replies)
Discussion started by: paolo.kunder
2 Replies
9. Shell Programming and Scripting
Hi,
I have fileA.txt like this.
B01B02 D0011718
B01B03 D0012540
B01B04 D0006145
B01B05 D0004815
B01B06 D0012069
B01B07 D0004064
B01B08 D0011988
B01B09 D0012071
B01B10 D0005596
B01B11 D0011351
B01B12 D0004814
B01C01 D0011804
I want to compare this against another file (fileB.txt)... (3 Replies)
Discussion started by: genehunter
3 Replies
10. Shell Programming and Scripting
HI,
I have two files and contains many Fields with | (pipe) delimitor, wanted to compare both the files and get only unmatched perticular fields. this i wanted to use in shell scriting.
ex:
first.txt
111 |abc| 230| hbc231 |bbb |210 |bbd405 |ghc |555 |cgv
second.txt
111 |abc |230 |hbc231... (1 Reply)
Discussion started by: prawinmca
1 Replies
LEARN ABOUT OPENSOLARIS
comm
comm(1) User Commands comm(1)
NAME
comm - select or reject lines common to two files
SYNOPSIS
comm [-123] file1 file2
DESCRIPTION
The comm utility reads file1 and file2, which must be ordered in the current collating sequence, and produces three text columns as output:
lines only in file1; lines only in file2; and lines in both files.
If the input files were ordered according to the collating sequence of the current locale, the lines written will be in the collating
sequence of the original lines. If not, the results are unspecified.
OPTIONS
The following options are supported:
-1 Suppresses the output column of lines unique to file1.
-2 Suppresses the output column of lines unique to file2.
-3 Suppresses the output column of lines duplicated in file1 and file2.
OPERANDS
The following operands are supported:
file1 A path name of the first file to be compared. If file1 is -, the standard input is used.
file2 A path name of the second file to be compared. If file2 is -, the standard input is used.
USAGE
See largefile(5) for the description of the behavior of comm when encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
EXAMPLES
Example 1 Printing a list of utilities specified by files
If file1, file2, and file3 each contain a sorted list of utilities, the command
example% comm -23 file1 file2 | comm -23 - file3
prints a list of utilities in file1 not specified by either of the other files. The entry:
example% comm -12 file1 file2 | comm -12 - file3
prints a list of utilities specified by all three files. And the entry:
example% comm -12 file2 file3 | comm -23 -file1
prints a list of utilities specified by both file2 and file3, but not specified in file1.
ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of comm: LANG, LC_ALL, LC_COLLATE,
LC_CTYPE, LC_MESSAGES, and NLSPATH.
EXIT STATUS
The following exit values are returned:
0 All input files were successfully output as specified.
>0 An error occurred.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWesu |
+-----------------------------+-----------------------------+
|CSI |enabled |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
SEE ALSO
cmp(1), diff(1), sort(1), uniq(1), attributes(5), environ(5), largefile(5), standards(5)
SunOS 5.11 3 Mar 2004 comm(1)