Operating System - HP-UX
1753400 Members
7165 Online
108792 Solutions
New Discussion

Re: Script needed (reformat file)

 
allanm77
Frequent Advisor

Script needed

Hi All,

 

Have a file which has a list of host, app & port -

 

host1

port1

app1

host2

port2

app2

host1

app2

port2

...

...

 

Need output in the following format-

 

host1:app1:PROD:port1

host2:app2:PROD:port2

 

where PROD is fixed text in it.

 

Thanks,

Allan.

 

 

 

1 REPLY 1
Dennis Handly
Acclaimed Contributor

Re: Script needed (reformat file)

awk '

BEGIN  { OFS=":" }

{

host=$0

getline port

getline app

print host, app, "PROD", port

} ' file