File Compare and Create New File with Diff

I need to compare File A with File B and create FILE C with the difference record only. What I mean is File A has 3 records and File B has 4 records, so FILE C will only have 1 record (becuase that record is in FILE B and not in File A). Hope I am making sense. The data layout is that each data element is within double quotes and each field is seperated by a comma. In the example below after the second name there is a double quote and 3 commas, the first comma is the field seperator and the other 2 commas are for fields that there is no data, hence the commas.

File A

"00000000155","JOHN","SMITH",,,"1944-06-03",
"00000001166","SMITH","JOHN",,,"1947-24-01",
""00000002189","BOB","SMITH",,,"1947-03-04",

File B

"00000000155","JOHN","SMITH",,,"1944-06-03",
"00000001166","SMITH","JOHN",,,"1947-24-01",
""00000002189","BOB","SMITH",,,"1947-03-04",
""00000002263","SMITH","JOHN",,,"1948-02-24",

I am not sure what uniz command to use, I haev done some reading and it looks like I can use the diff command or maybe even teh awk command. If someone can provide assistance here , I would be greatly appreciate it.

Sincerely

Hm, try using the comm command. Its does exactly what you want to do.

Thanks for your resposne, but I tried the comm command and it is not working, this si what I tried

comm -23 file1 file2

Any assistance would be greatly apprecaited.

Thanks

Both files need to be sorted first for comm to work.

I had posted this earlier about 3 weeks ago and had recieved a response and I did sort both the files and the comm command is still not working.

Can someone please assist me, I would really appreciate it.

Below is what I am trying to do
I need to compare File A with File B and create FILE C with the difference record only. What I mean is File A has records and File B has records, so FILE C will only have the records which are not in File A. Hope I am making sense. The data layout is that each data element is within double quotes and each field is seperated by a comma. In the example below after the second name there is a double quote and 3 commas, the first comma is the field seperator and the other 2 commas are for fields that there is no data, hence the commas

Below are the sample file layout

File A

"00004006676","JOHN","SMITH",,,"1944-06-03",
"00004200004","JOHN","SMITH",,,"1944-06-03",
"00004200075","JOHN","SMITH",,,"1944-06-03",
"00004200101","JOHN","SMITH",,,"1944-06-03",
"00004200155","JOHN","SMITH",,,"1944-06-03",
"00004200245","JOHN","SMITH",,,"1944-06-03",
"00004200318","JOHN","SMITH",,,"1944-06-03",
"00004201166","JOHN","SMITH",,,"1944-06-03",
"00004202042","JOHN","SMITH",,,"1944-06-03",
"00004202189","JOHN","SMITH",,,"1944-06-03",
"00004202234","JOHN","SMITH",,,"1944-06-03",
"00004202263","JOHN","SMITH",,,"1944-06-03",
"00004202298","JOHN","SMITH",,,"1944-06-03",
"00004202365","JOHN","SMITH",,,"1944-06-03",
"00004202373","JOHN","SMITH",,,"1944-06-03",
"00004202491","JOHN","SMITH",,,"1944-06-03",
"00004202640","JOHN","SMITH",,,"1944-06-03",
"00004202745","JOHN","SMITH",,,"1944-06-03",
"00004202994","JOHN","SMITH",,,"1944-06-03",
"00004203032","JOHN","SMITH",,,"1944-06-03",
"00004203044","JOHN","SMITH",,,"1944-06-03",
"00004203238","JOHN","SMITH",,,"1944-06-03",
"00004203539","JOHN","SMITH",,,"1944-06-03",
"00004203553","JOHN","SMITH",,,"1944-06-03",
"00004203655","JOHN","SMITH",,,"1944-06-03",
"00004203669","JOHN","SMITH",,,"1944-06-03",
"00004203722","JOHN","SMITH",,,"1944-06-03",
"00004203762","JOHN","SMITH",,,"1944-06-03",
"00004203860","JOHN","SMITH",,,"1944-06-03",
"00004203887","JOHN","SMITH",,,"1944-06-03",
"00004207046","JOHN","SMITH",,,"1944-06-03",

File B

"00004006676","JOHN","SMITH",,,"1944-06-03",
"00004200004","JOHN","SMITH",,,"1944-06-03",
"00004200075","JOHN","SMITH",,,"1944-06-03",
"00004200101","JOHN","SMITH",,,"1944-06-03",
"00004200125","JOHN","SMITH",,,"1944-06-03",
"00004200130","JOHN","SMITH",,,"1944-06-03",
"00004200155","JOHN","SMITH",,,"1944-06-03",
"00004200245","JOHN","SMITH",,,"1944-06-03",
"00004200318","JOHN","SMITH",,,"1944-06-03",
"00004201166","JOHN","SMITH",,,"1944-06-03",
"00004202042","JOHN","SMITH",,,"1944-06-03",
"00004202189","JOHN","SMITH",,,"1944-06-03",
"00004202234","JOHN","SMITH",,,"1944-06-03",
"00004202263","JOHN","SMITH",,,"1944-06-03",
"00004202298","JOHN","SMITH",,,"1944-06-03",
"00004202307","JOHN","SMITH",,,"1944-06-03",
"00004202365","JOHN","SMITH",,,"1944-06-03",
"00004202373","JOHN","SMITH",,,"1944-06-03",
"00004202491","JOHN","SMITH",,,"1944-06-03",
"00004202640","JOHN","SMITH",,,"1944-06-03",
"00004202745","JOHN","SMITH",,,"1944-06-03",
"00004202994","JOHN","SMITH",,,"1944-06-03",
"00004203032","JOHN","SMITH",,,"1944-06-03",
"00004203238","JOHN","SMITH",,,"1944-06-03",
"00004203539","JOHN","SMITH",,,"1944-06-03",
"00004203553","JOHN","SMITH",,,"1944-06-03",
"00004203655","JOHN","SMITH",,,"1944-06-03",
"00004203669","JOHN","SMITH",,,"1944-06-03",
"00004203722","JOHN","SMITH",,,"1944-06-03",
"00004203762","JOHN","SMITH",,,"1944-06-03",
"00004203860","JOHN","SMITH",,,"1944-06-03",
"00004203887","JOHN","SMITH",,,"1944-06-03",
"00004207046","JOHN","SMITH",,,"1944-06-03",

The final results in File C would be the following records since these records are in File B and not in File A

"00004200125","JOHN","SMITH",,,"1944-06-03",
"00004200130","JOHN","SMITH",,,"1944-06-03",
"00004202307","JOHN","SMITH",,,"1944-06-03",

Sincerely

Hadi Lalani

guiguy, I just closed a duplicate thread and I see that vino had to edit your post to remove your email address. Please read the rules:

(4) Do not 'bump up' questions if they are not answered promptly. No duplicate or cross-posting and do not report a post where your goal is to get an answer more quickly.

(10) Don't post your email address and ask for an email reply. The forums are for the benefit of all, so all Q&A should take place in the forums.

As for your question, I copied your data into files which I named file_A and file_B. Then I tried:

$ comm -13 file_A file_B
"00004200125","JOHN","SMITH",,,"1944-06-03",
"00004200130","JOHN","SMITH",,,"1944-06-03",
"00004202307","JOHN","SMITH",,,"1944-06-03",
$
$

The man page is clear that comm -13 is what you need. You were suppressing the wrong column. You tried:
comm -23
which was wrong. There are only two other ways to print a single column:
comm -13
comm -12

Why not try them before you give up?

How to get the common columns in two files that are not sorted...?

First sort the files and then use this

comm -3 file1.sort file2.sort