The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-23-2008
axwack axwack is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 1
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.
  #2 (permalink)  
Old 10-23-2008
avis1981 avis1981 is offline
Registered User
  
 

Join Date: Oct 2008
Location: NC
Posts: 21
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:47 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0