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
How to combine 2 different files rdasari HP-UX 1 03-17-2008 05:19 PM
combine two files fredao1 Shell Programming and Scripting 1 01-08-2007 09:29 PM
Combine 2 files Nekki UNIX for Dummies Questions & Answers 2 12-01-2005 02:46 AM
How to combine 2 files ravi.sadani19 Shell Programming and Scripting 2 07-12-2005 05:04 AM
how to combine two files tao UNIX for Dummies Questions & Answers 4 03-21-2002 10:38 PM

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 02-19-2007
goodmis goodmis is offline
Registered User
  
 

Join Date: Jan 2007
Posts: 24
Need To Combine 2 Files

I have 2 files that I need to combine.

One file is looks like this:

71664107;1;1;05-FEB-07;12-FEB-07;

The other file looks like this:

U;71664107;dummy;Pirovano;M;04-SEP-75;Georgia;MI;1;1;31;S;S;;;Y;05-02-2007;0;12-FEB-07;

I need to combine both files together. I need the shorter file added to the end of the longer file based on the common # 71664107.

I have tried using get line but sometimes it does not work.

Any suggestions?
  #2 (permalink)  
Old 02-19-2007
sb008 sb008 is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 384
Quote:
Originally Posted by goodmis
I have 2 files that I need to combine.

One file is looks like this:

71664107;1;1;05-FEB-07;12-FEB-07;

The other file looks like this:

U;71664107;dummy;Pirovano;M;04-SEP-75;Georgia;MI;1;1;31;S;S;;;Y;05-02-2007;0;12-FEB-07;

I need to combine both files together. I need the shorter file added to the end of the longer file based on the common # 71664107.

I have tried using get line but sometimes it does not work.

Any suggestions?
Isn't all the information of the file with the short lines already in the file with the long lines?

U;71664107;dummy;Pirovano;M;04-SEP-75;Georgia;MI;1;1;31;S;S;;;Y;05-02-2007;0;12-FEB-07;

So you might be able to use:
nawk 'BEGIN { FS=";" } { print $0 $2";"$9";"$10";"$17";"$19";" }' <longfile>
  #3 (permalink)  
Old 02-19-2007
goodmis goodmis is offline
Registered User
  
 

Join Date: Jan 2007
Posts: 24
No The Files Are Not The Same

I have two files that I need to combine. The information is similar but 1 file is larger than the other. They must be combined.

Thanks
  #4 (permalink)  
Old 02-19-2007
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,409
If the files are sorted correctly, then try using join...
Code:
$ head file[12]
==> file1 <==
71664107;1;1;05-FEB-07;12-FEB-07;

==> file2 <==
U;71664107;dummy;Pirovano;M;04-SEP-75;Georgia;MI;1;1;31;S;S;;;Y;05-02-2007;0;12-FEB-07;

$ join -t ';' -1 2 -2 1 file2 file1
71664107;U;dummy;Pirovano;M;04-SEP-75;Georgia;MI;1;1;31;S;S;;;Y;05-02-2007;0;12-FEB-07;;1;1;05-FEB-07;12-FEB-07;

  #5 (permalink)  
Old 02-21-2007
gopidesaboyina gopidesaboyina is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 29
If they are in sorted format and lines matches. just use below command.

paste long_file short_file
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 11:41 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