Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reading 2 files to create a third file 1

Status
Not open for further replies.

adimstec

IS-IT--Management
Nov 27, 2002
52
FR
Hello,

I have to write a script for this purposes :



I have 2 files:

cat file1
vpath9 vpath27
vpath14 vpath32


cat file2
vpath9 610
vpath27 888
vpath14 612
vpath32 322

I would like to change file1 by using file2 in order to have a third file like this

output file:
610 888
612 322

Any helps ?
 
A starting point:
awk 'NR==FNR{a[$1]=$2;next}{print a[$1],a[$2]}' file2 file1

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thankx PHV
As usual you gave me a good hint.

If I don't abuse , now I would like to have this result:

Output file

vpath9 610 vpath27 888

 
awk 'NR==FNR{a[$1]=$2;next}{print $1,a[$1],$2,a[$2]}' file2 file1

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thankx PHV, it works.

And now, I have another deal :

In a AIX server, I need to write a script that create a file with all the disk configuration, something like :

VG1:LV1:FS1:Size
VG2:LV2:FS2:Size
------

I am sure you already have a script doing it :)

Thankx again in advance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top