![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Compare & replace contents within a file | kaustubh137 | Shell Programming and Scripting | 2 | 05-27-2008 07:56 AM |
| compare array contents with file | orahi001 | UNIX for Dummies Questions & Answers | 0 | 03-25-2008 05:44 PM |
| Compare two arrays in sh or compare two fields | rijeshpp | Shell Programming and Scripting | 0 | 10-31-2007 02:47 AM |
| Cut rows | obedkhan | HP-UX | 2 | 08-23-2006 10:36 AM |
| Creating file contents using contents of another file | ReV | Shell Programming and Scripting | 21 | 02-24-2006 10:25 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
How to compare contents of two CSV rows
I have been trying to find the answer to this but can't seem to get it.
I have two rows, both are CSV files. I want to iteratively compare each field value to the corresponding value in the second file. Example: File 1.txt 1|hello|3.2|AMB||||B File 2.txt 1|hi|3,2|ABC||||C The result should spit out only the differences in 2.txt Field $2: hi Field $4: ABC etc. I have a feeling this is an AWK program but I'm new to it so if there is a one liner that can get me close then I would be interested. THanks in advance. |
|
||||
|
How about first joining the file
join -t"|" 1.txt 2.txt|awk 'BEGIN{FS="|"} $2!=$9 {print 2,$9}' Above does for field 2,Similarly need to do for other fields This is assuming 8 fields are there in the file. Last edited by avis1981; 10-23-2008 at 07:56 PM.. Reason: Improving clarity |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|