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
unix script for update or insert records from a file to a oracle table unihp1 UNIX for Advanced & Expert Users 1 06-11-2008 03:21 AM
Script required to get a required info from file. Pls. help me. ntgobinath Shell Programming and Scripting 2 05-31-2008 08:34 AM
Help required with a Csh script to read data from a file fizzme Shell Programming and Scripting 1 05-29-2008 07:30 PM
Count No of Records in File without counting Header and Trailer Records guiguy Shell Programming and Scripting 2 06-07-2007 12:15 PM
finding null records in data file dsravan Shell Programming and Scripting 3 01-09-2007 03:46 PM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 07-04-2008
RRVARMA's Avatar
RRVARMA RRVARMA is offline
Registered User
  
 

Join Date: Feb 2008
Location: Bangalore, INDIA
Posts: 34
awk script required for finding records in 1 file with corresponding another file.

Hi,

I have a .txt file (uniqfields.txt) with 3 fields separated by " | " (pipe symbol). This file contains unique values with respect to all these 3 fields taken together. There are about 40,000 SORTED records (rows) in this file. Sample records are given below.

Code:
1TVAO|OVEPT|VO
1TVAO|OVPDM|VO
6NFXE|17CLP|DH
6NFXE|NRZO4|EQ
6NFXE|SMOSA|EQ
ACA15|11X1W|DX
ACA15|1LN88|DX
ACA15|1LNSK|DX
ACA15|1LNVX|DX
ACA15|1LNVX|FD
Now, there is another file (mainfile.txt) which contains 23 fields(columns), which contains the above fields as 7th, 13th and 14th field respectively. This file ie, mainfile.txt is also sorted and is seperated by pipe symbol. This file contains about 77,000 records. The 7th, 13th & 14th columns are from with in the above values only, but some records(rows) are repeated (with respect to these 3 fields(columns), other fields(columns) may or maynot be same.

What i need to do now is to compare first record (1st row) of uniqfields.txt with that of mainfile.txt and fetch first record (row) which contains all the above 3 fields same. That is, 1st field from uniqfields.txt should match with 7th column of mainfile.txt AND 2nd of uniqfields.txt with 13th of mainfile.txt AND 3rd of uniqfields.txt with 14th of mainfile.txt.

Why this is required with awk script..??

1) As i'm new to unix, i'm just catchin up wit awk and i'm not able to find a solution myself.
2) I tried with sort -t\| -u +6 -7 +12 -14 mainfile.txt > uniqmainfile.txt, but its working fine in SunOS and not working on NCR MP-RAS.
Actually, we are migrating these from server with SunOS to server with NCR MP-RAS. So, in SunOS, if i run the sort script just mentioned above, its fetching the first unique record, whereas in NCR MP-RAS its fetching the last unique record.

How does it impact if it takes last or first among from similar records..??

Actually, as we are checking for uniqueness only in the 7th, 13th and 14th fields(columns), the other fields(columns) are not matched with the reports in MP-RAS with that of SunOS.

I've tried with -r and tried using uniq command as well,but in vain. And found that the only solution is using awk.

Please help me in this regard.

Thanks,
RRVARMA
 

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 09:39 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