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 > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
merging two files rameshonline Shell Programming and Scripting 14 04-06-2009 01:20 AM
merging of 2 files AWK, SHELL or something else klut Shell Programming and Scripting 24 03-20-2009 09:45 AM
merging text files code19 Shell Programming and Scripting 8 02-13-2008 08:13 AM
merging INPUT and files fiol73 UNIX for Dummies Questions & Answers 1 01-01-2007 05:14 PM
Merging fileds from 2 files Mudshark Shell Programming and Scripting 8 04-19-2005 01:49 PM

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 01-10-2008
venommaker venommaker is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 3
Merging two files

Hi I have a requirement like this.

I have two files
This is how data1.txt looks:
EI3171280 38640658501 NENN2005-12-129999-12-312005-12-12HALL NANCY 344 CHENEY HIGHWAY TITUSVILLE FL32780-0000 N 1-1192515160
PI95000M 23326685801 NENN2005-12-121924-02-172005-12-12POLING EARL W 2600-26TH AVE PARKERSBURG WV26101-0000 N 1-1192669087
EI3212756 58007867001 NSNN2005-12-121936-09-192005-12-12CRUZ AIDA P.O. BOX 1295 KINGSHILL,ST. C VI00851 N 1-1193006037
EI3210432 05128396601 NENN2005-12-121933-04-132005-12-12NERKO ELEANORE 60-16-76TH ST ELMHURST NY11373-2417 N 1-1192833610
EI3206592 23560778101 NENN2005-12-121941-08-312005-12-12SLAUGHTER CARL G 452 EAST FAIRLAWN DRIVE COVINGTON VA24426-0000 N 1-1192854020
PI25802 04738568501 NENN2005-12-121947-09-272005-12-12VLECIDES CONSTANTINE 27 WIND HILL WAY HOLMDEL NJ07733-1134 N 1-1192966250
EI3209792 43224032301 NENN2005-12-121916-01-192005-12-12SIMPSON LOUISE E 1102 DALINE SPRINGDALE AR72764-0000 N 1-1192968873
NI2429593 76420731101 NSNN2005-12-121974-01-282005-12-12RAMIREZ PEDRO 414 W PENNSYLVANIA TUCSON AZ85714 N 1-1193264262
EI3309644 61719151504 NSNN2005-12-121999-02-232005-12-12SANDOVAL ANDRES 1727 ROSE AVE SANTA ROSA CA95407-0000 N 1-1193559416
EI3308928 43065868602 NENN2005-12-121968-03-022005-12-12MILLS SR JOHN D 906 HOGAN DR MURFREESBORO TN37128-0000 N 1-1193399232
EI3308972 46825707401 NENN2005-12-121985-03-082005-12-12LEFEVRE STEPHANIE 17175 WALNUT LANE SPIRIT LAKE IA51360-0000 N 1-1193538259
999999 ICARE 2005-12-13 000000011

Please copy it into notepad without wordwrap to have a proper view.


Next data2.txt appears like this:

JI3209792 43224032301 NENN2005-12-121916-01-192005-12-12SIMPSON LOUISE E 1102 DALINE SPRINGDALE AR72764-0000 N 1-1192968873
NI2429593 76420731101 NSNN2005-12-121974-01-282005-12-12RAMIREZ PEDRO 414 W PENNSYLVANIA TUCSON AZ85714 N 1-1193264262
JI3309644 61719151504 NSNN2005-12-121999-02-232005-12-12SANDOVAL ANDRES 1727 ROSE AVE SANTA ROSA CA95407-0000 N 1-1193559416
JI3308928 43065868602 NENN2005-12-121968-03-022005-12-12MILLS SR JOHN D 906 HOGAN DR MURFREESBORO TN37128-0000 N 1-1193399232
JI3308972 46825707401 NENN2005-12-121985-03-082005-12-12LEFEVRE STEPHANIE 17175 WALNUT LANE SPIRIT LAKE IA51360-0000 N 1-1193538259
999999 ICARE 2005-12-13 000000005

So the lines marked in the two files indicates the line count for each file. for the first file its 11 and for the next one its five. This is a common field for both the files.
Now what i need is to merge these two files like this

EI3171280 38640658501 NENN2005-12-129999-12-312005-12-12HALL NANCY 344 CHENEY HIGHWAY TITUSVILLE FL32780-0000 N 1-1192515160
PI95000M 23326685801 NENN2005-12-121924-02-172005-12-12POLING EARL W 2600-26TH AVE PARKERSBURG WV26101-0000 N 1-1192669087
EI3212756 58007867001 NSNN2005-12-121936-09-192005-12-12CRUZ AIDA P.O. BOX 1295 KINGSHILL,ST. C VI00851 N 1-1193006037
EI3210432 05128396601 NENN2005-12-121933-04-132005-12-12NERKO ELEANORE 60-16-76TH ST ELMHURST NY11373-2417 N 1-1192833610
EI3206592 23560778101 NENN2005-12-121941-08-312005-12-12SLAUGHTER CARL G 452 EAST FAIRLAWN DRIVE COVINGTON VA24426-0000 N 1-1192854020
PI25802 04738568501 NENN2005-12-121947-09-272005-12-12VLECIDES CONSTANTINE 27 WIND HILL WAY HOLMDEL NJ07733-1134 N 1-1192966250
EI3209792 43224032301 NENN2005-12-121916-01-192005-12-12SIMPSON LOUISE E 1102 DALINE SPRINGDALE AR72764-0000 N 1-1192968873
NI2429593 76420731101 NSNN2005-12-121974-01-282005-12-12RAMIREZ PEDRO 414 W PENNSYLVANIA TUCSON AZ85714 N 1-1193264262
EI3309644 61719151504 NSNN2005-12-121999-02-232005-12-12SANDOVAL ANDRES 1727 ROSE AVE SANTA ROSA CA95407-0000 N 1-1193559416
EI3308928 43065868602 NENN2005-12-121968-03-022005-12-12MILLS SR JOHN D 906 HOGAN DR MURFREESBORO TN37128-0000 N 1-1193399232
EI3308972 46825707401 NENN2005-12-121985-03-082005-12-12LEFEVRE STEPHANIE 17175 WALNUT LANE SPIRIT LAKE IA51360-0000 N 1-1193538259
JI3209792 43224032301 NENN2005-12-121916-01-192005-12-12SIMPSON LOUISE E 1102 DALINE SPRINGDALE AR72764-0000 N 1-1192968873
NI2429593 76420731101 NSNN2005-12-121974-01-282005-12-12RAMIREZ PEDRO 414 W PENNSYLVANIA TUCSON AZ85714 N 1-1193264262
JI3309644 61719151504 NSNN2005-12-121999-02-232005-12-12SANDOVAL ANDRES 1727 ROSE AVE SANTA ROSA CA95407-0000 N 1-1193559416
JI3308928 43065868602 NENN2005-12-121968-03-022005-12-12MILLS SR JOHN D 906 HOGAN DR MURFREESBORO TN37128-0000 N 1-1193399232
JI3308972 46825707401 NENN2005-12-121985-03-082005-12-12LEFEVRE STEPHANIE 17175 WALNUT LANE SPIRIT LAKE IA51360-0000 N 1-1193538259
999999 ICARE 2005-12-13 000000016

with the count for the merged file changed to 16 now. This is all i need..could you please help me with this.. am very naive in this..
please advise..
thanks

Last edited by venommaker; 01-10-2008 at 08:13 AM..
  #2 (permalink)  
Old 01-10-2008
thana thana is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 55
paste first_file second_file > third_file

cat third_file
  #3 (permalink)  
Old 01-10-2008
venommaker venommaker is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 3
hi thana,
this will create a duplicate entry of this line
999999 ICARE 2005-12-13 000000005

but i need only entry with an updated count also..your suggestion will just merge them..wont increase the line count!!
  #4 (permalink)  
Old 01-10-2008
rein rein is offline
Registered User
  
 

Join Date: Dec 2004
Location: Zürich
Posts: 146
You could use the uniq command for this.
  #5 (permalink)  
Old 01-10-2008
venommaker venommaker is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 3
could you tell me exactly how to do this?? i am pretty new to this whole unix stuff!!
thanks
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 12:39 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