![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Check File Exists and compare to previous day file script | rbknisely | Shell Programming and Scripting | 3 | 02-07-2008 11:53 AM |
| compare file size from a output file from a script | moustik | Shell Programming and Scripting | 7 | 11-07-2007 10:17 AM |
| Compare/Diff between directories and subdirectories? | andylee80 | UNIX for Dummies Questions & Answers | 5 | 07-12-2007 09:45 AM |
| diff 2 files; output diff's to 3rd file | blt123 | Shell Programming and Scripting | 2 | 05-28-2002 11:29 AM |
| How to compare prev day file to current day file | Smurtzy | Shell Programming and Scripting | 1 | 12-05-2001 07:33 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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 |
|
||||
|
File Compare in Unix
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:47 PM.. Reason: remove email address... |
|
|||||
|
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: Code:
$ comm -13 file_A file_B "00004200125","JOHN","SMITH",,,"1944-06-03", "00004200130","JOHN","SMITH",,,"1944-06-03", "00004202307","JOHN","SMITH",,,"1944-06-03", $ $ 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 for files not sorted
Quote:
How to get the common columns in two files that are not sorted...? |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|