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
Joining 2 CSV files together chachabronson UNIX for Advanced & Expert Users 3 05-06-2008 06:42 AM
Problem joining 2 files rochitsharma UNIX for Advanced & Expert Users 4 04-03-2008 06:12 AM
Joining lines from two files - please help chandra004 Shell Programming and Scripting 25 07-27-2006 02:39 AM
joining files Manu UNIX for Dummies Questions & Answers 2 04-25-2005 12:24 PM
joining 2 files webtekie UNIX for Dummies Questions & Answers 1 10-21-2003 10:51 AM

 
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 09-27-2006
rjlohman rjlohman is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 5
Help with joining two files

Greetings, all. I've got a project that requires I join two data files together, then do some processing and output. Everything must be done in a shell script, using standard unix tools. The files look like the following:

File_1
Layout:
Acct#,Subacct#,Descrip
Sample:
0001,0001,Account1/Sub1
0001,0002,Account1/Sub2
0002,0001,Account2/Sub1
0002,0002,Account2/Sub2
0002,0003,Account2/Sub3
...

File_2
Layout:
TransID,Code,Acct#,SubAcct#,Date,To,For,Amount,Ref#
Sample:
1,D,0002,0001,2006-01-03,Joe,Services,35.00,1234
2,C,0002,0003,2006-01-05,Mary,PC Repair,50.00,
3,D,0001,0001,2006-01-05,Amazon.com,book,39.95,1235
...

In essence, I need to add the proper description from File_1 into each record of File_2. Once the join is complete, I plan on using awk to summarize the data and output, so order is not important (description can go in right after the acct# & subacct# columns in File_2, or it can be appended to the end of each line).

I've tried join already, but since join expects to match on a single field, and I'm trying to match on two fields, join hasn't been much help. I've also tried sed, but I can't seem to get the replacement syntax right.

Any help would be greatly appreciated.

Rich Lohman
 

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 10: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