The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 2 flat files ganesh123 Shell Programming and Scripting 5 03-16-2007 02:04 PM
How to compare two flat files and get changed data jtshashidhar Shell Programming and Scripting 3 01-29-2006 10:26 PM
Compare data in 2 files and delete if file exist lweegp Shell Programming and Scripting 3 10-13-2005 06:35 AM
Compare data files ithomp Shell Programming and Scripting 1 06-15-2004 10:08 AM
compare update time of files dorilevy UNIX for Dummies Questions & Answers 8 05-27-2003 09:48 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-03-2005
rajus19 rajus19 is offline
Registered User
  
 

Join Date: Feb 2005
Location: Bangalore
Posts: 36
How to compare data in two flat files and update them?

Hi All,

I am giving an example similar to the problem I have.
I have two data files of 10 columns each in which fields are delimited by comma(,). I need to compare compare the two files using the uniq col(col3). If there are any records in file1 and are not in file2 then I have check the value for col4 of those records from a database table, if its success then I have to include those records in file2 and have to change the value of col6 to "updated".

Can you please give me an idea how to implement in a shell script.

your help will be greatly appreciated.

Thanks in Advance.
Raju
  #2 (permalink)  
Old 11-04-2005
Abhishek Ghose Abhishek Ghose is offline
Registered User
  
 

Join Date: Sep 2005
Location: Chennai
Posts: 81
Not very sure on the requirement but have you tried the UNIX 'join' command?
  #3 (permalink)  
Old 11-08-2005
rajus19 rajus19 is offline
Registered User
  
 

Join Date: Feb 2005
Location: Bangalore
Posts: 36
Could you please suggest me how to replace two fields in a flat file which contains more than 40 fields.

If I use sed by searching for the strings there may be a chance that the same string occurs in other fields also.

If I use awk I explicitly metion the rest of the 38 fields.

Please suggest me how to deal with this.

Thanks in advance
Raju
  #4 (permalink)  
Old 11-08-2005
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
to change the 2-nd and the 5-th fields in the file "myFile"
nawk '{$2="foo"; $5="bar"; print}' myFile
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:07 PM.


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