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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Colon delimited output query

Status
Not open for further replies.

ranjit

Technical User
Apr 14, 2000
131
GB
I am attempting to create a colon delimited text file of the format:

Text header:pKG name:Version:Modified date

The input file and desired output is as shown below...could someone possibly assist?
Thanks in advance.

[tt]
Input file:

Name : mtools Relocations: /opt/freeware
Version : 3.9.8 Vendor: (none)
Install date: Fri 30 Apr 10:48:07 2004 Build Host: emp.austin.ibm.com
Name : cdrecord Relocations: /opt/freeware
Version : 1.9 Vendor: (none)
Install date: Fri 30 Apr 10:48:09 2004 Build Host: emp.austin.ibm.com
Name : mkisofs Relocations: /opt/freeware
Version : 1.13 Vendor: (none)
Install date: Fri 30 Apr 10:48:10 2004 Build Host: emp.austin.ibm.com
Name : AIX-rpm Relocations: (not relocateable)
Version : 5.1.0.35 Vendor: (none)
Install date: Fri 30 Apr 11:13:26 2004 Build Host: loopback
Name : openssl Relocations: /opt/freeware
Version : 0.9.6m Vendor: (none)
Install date: Fri 30 Apr 13:47:21 2004 Build Host: del.austin.ibm.com

Desired output:

rpm_info:mtools:3.9.8:Fri 30 Apr 2004
rpm_info:cdrecord:1.9:Fri 30 Apr 2004
rpm_info:mkisofs:1.13:Fri 30 Apr 2004
rpm_info:AIX-rpm:5.1.0.35:Fri 30 Apr 2004
rpm_info:eek:penssl:0.9.6m:Fri 30 Apr 2004
[/tt]
 
Something like this ?
awk '
/^Name/{n=$3}
/^Version/{v=$3}
/^Install date/{printf "rpm_info:%s:%s:%s %s %s %s\n",n,v,$3,$4,$5,$7}
' /path/to/input

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top