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

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Awk from two files into one file

Reply to Message Icon

Name: xoir
Date: April 27, 2004 at 14:11:32 Pacific
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



Sponsored Link
Ads by Google

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

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.


0

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

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


0

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

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Awk from two files into one file

Awk: parsing multiple files into one www.computing.net/answers/unix/awk-parsing-multiple-files-into-one/8410.html

Listing two files as one long list www.computing.net/answers/unix/listing-two-files-as-one-long-list/6062.html

gzip multiple files into one www.computing.net/answers/unix/gzip-multiple-files-into-one/7121.html