Computing.Net > Forums > Unix > Awk from two files into one file

Awk from two files into one file

Reply to Message Icon

Original Message
Name: xoir
Date: April 27, 2004 at 14:11:32 Pacific
Subject: Awk from two files into one file
OS: solaris
CPU/Ram: ultra 5
Comment:

Hi!

I’m trying to load two files in to one file

File-1 said:

A1 = 20
A2 = 10
A3 = 30
A4 = 15
A5 = 60

File-2 said:

A1 = iface-1
A2 = iface-2
A3 = iface-3
A4 = iface-4
A5 = iface-5

And I need a File-3 like this:

iface-1,20
iface-2,10
iface-3,30
iface-4,15
iface-5,60

any suggestion?

Regards
RRV


Report Offensive Message For Removal


Response Number 1
Name: Wolfbone
Date: April 27, 2004 at 16:14:25 Pacific
Reply: (edit)

If the records are in ordered one to one correspondence as they are in your example:

awk '{str = $3 ; getline < "File-1" ; print str "." $3 > "File-3"}' File-2

If not, ask again.


Report Offensive Follow Up For Removal

Response Number 2
Name: Wolfbone
Date: April 27, 2004 at 17:28:59 Pacific
Reply: (edit)

Replace 'str "." $3' with 'str "," $3' if you must have commas. ;)


Report Offensive Follow Up For Removal

Response Number 3
Name: xoir
Date: April 28, 2004 at 15:07:01 Pacific
Reply: (edit)

the values arent one to one, but I could figure how to sort the records to load in the right position in order from one to one.

Thanks Wolfbone!!

RRV


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Awk from two files into one file

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge