Help- Unix File Compare- Struggling


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Help- Unix File Compare- Struggling
# 1  
Old 01-06-2007
Help- Unix File Compare- Struggling

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

Last edited by vino; 01-06-2007 at 03:44 PM.. Reason: remove email address..
# 2  
Old 01-06-2007
Try the diff command, you will need to script it to format the output the way you want it and send the output to a new file.
Tornado
# 3  
Old 01-06-2007
I am closing this duplicate thread.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

File compare in UNIX

I have two files which is having components and its version inside that, cat file1 com.acc.invm:FNS_PROD com.acc.invm:FNS_TEST_DCCC_Mangment com.acc.invm:FNS_APIPlat_BDMap com.acc.invm:SendEmail com.acc.invm:SendSms cat file2 com.acc.invm:FNS_PROD 94.0.5... (11 Replies)
Discussion started by: rakeshtomar82
11 Replies

2. UNIX for Dummies Questions & Answers

Compare two file in UNIX

Hi, how to compare all the differences from two files in unix ? plz provide the screenshots. Thanks, Dasaradha (1 Reply)
Discussion started by: dasaradha
1 Replies

3. Homework & Coursework Questions

Compare to values in a file in unix

Here is sample file ===============Index 0=================== isActive=0, Input=1, Output=1, Status=1 State = Future , PRIMARY UnderCount=2 inCount=2 outCount=0 SCount=673 -- ===============Index 1=================== isActive=0, Input=1, Output=1, Status=1 ... (1 Reply)
Discussion started by: sooda
1 Replies

4. Shell Programming and Scripting

Parsing file: struggling against sed command

Hello fellows, Sure you can help this poor guy that is struggling against sed command, being unable to tame it I have a lot of files like this: From this one, I need to obtain values highlighted in bold/red To do so, I am executing this piece of code inside a loop: ... (10 Replies)
Discussion started by: manolain
10 Replies

5. Shell Programming and Scripting

Struggling with arrays and delimited file

Hi, I am trying to use arrays in my script but can not seem to get it to work. I have a file called sections, this contains headers from a tripwire log file, separated by "@" but could be "," if easier The headers will be used to cut sections from the log file into another to be mailed. ... (5 Replies)
Discussion started by: pobman
5 Replies

6. Shell Programming and Scripting

Unix script to compare the two file

Hi, I want to compare two | delimited files.Awk is not working in my unix box.So plz give alternate solutions. Please see the below code: file1=$1 file2=$2 num_of_records_file1=`awk ' END { print NR } ' $file1` num_of_records_file2=`awk ' END { print NR } ' $file2` i=1 while do... (4 Replies)
Discussion started by: autosys_nm
4 Replies

7. Programming

compare XML/flat file with UNIX file system structure

Before i start doing something, I wanted to know whether the approach to compare XML file with UNIX file system structure. I have a pre-configured file(contains a list of paths to executables) and i need to check against the UNIX directory structure. what are the various approches should i use ? I... (6 Replies)
Discussion started by: shafi2all
6 Replies

8. Shell Programming and Scripting

Struggling with a text file

Hi, I am struggling with the following... I try to grep out information of a text file I got with lynx, a text browser. The text file I get from lynx with dump is attached in the bottom. What I would like to get is another file containing the astro-ph/98324 (number) and title and list of... (13 Replies)
Discussion started by: pau
13 Replies
Login or Register to Ask a Question