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!

from 2 files create 1 2

Status
Not open for further replies.

adimstec

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

Another deal :

I have 2 files FIC1 and FIC2 and I need to create a third one named FIC

FIC1
VG1:data1:data2:data3:data4
VG2:data5:data6:data7:data8

FIC2
VG1:disk1
VG1:disk2
VG2:disk3
VG2:disk4
VG2:disk5
VG2:disk6


FIC
VG1:data1:data2:data3:data4:disk1:disk2
VG2:data5:data6:data7:data8:disk3:disk4:disk5:disk6


Thank you in advance.

 
Something like this ?
awk 'BEGIN{FS=OFS=":"}{v=$1;$1="";a[v]=a[v] $0}END{for(i in a)print i a}' FIC1 FIC2 > FIC

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Code:
awk -F: '
        { for (i=2;i<=NF;i++) { a[$1]=a[$1]":"$i } }
        END { for (i in a) { print i a[i] } }
' FIC1 FIC2

Annihilannic.
 
PHV, Annihilannic : TOTAL RESPECT , it works great !

Chacalinc : you are probably rigth , I should read a awk's manual but because I needed a quick solution, I knew I can find it in this place with people like PHV or Annihilannic.

Again, Thank you anf you can be very proud of yourself !

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top