Hello techies
I am trying to print key-value pairs specifically:
the date and time and the values for HOST and USER
This is the sample input text.
[pre] <txt>20-JUL-2015 07:58:22 * (CONNECT_DATA=(SID=ORADB3)(CID=(PROGRAM=perl)(HOST=winserver5)(USER=oem))) * (ADDRESS=(PROTOCOL=tcp)(HOST=10.10.10.10)(PORT=12345)) * establish * ORADB3 * 0
<txt>20-JUL-2015 07:58:38 * (CONNECT_DATA=(SID=ORADB4)(CID=(PROGRAM=)(HOST=__jdbc__)(USER=))) * (ADDRESS=(PROTOCOL=tcp)(HOST=10.10.10.10)(PORT=12345)) * establish * ORADB4 * 0
<txt>20-JUL-2015 08:01:09 * (CONNECT_DATA=(CID=(PROGRAM=JDBC Thin Client)(HOST=__jdbc__)(USER=ZAHIER))(SERVICE_NAME=ORADB6)(CID=(PROGRAM=JDBC Thin Client)(HOST=__jdbc__)(USER=ZAHIER))) * (ADDRESS=(PROTOCOL
=tcp)(HOST=10.10.10.10)(PORT=12345)) * establish * ORADB6 * 0[/pre]
I am working on Solaris 10 and tried using sed & awk (see below) to remove the text that I DO NOT want - but this is clearly inefficient.
How do I extract just the fields that I need?
I am trying to print key-value pairs specifically:
the date and time and the values for HOST and USER
This is the sample input text.
[pre] <txt>20-JUL-2015 07:58:22 * (CONNECT_DATA=(SID=ORADB3)(CID=(PROGRAM=perl)(HOST=winserver5)(USER=oem))) * (ADDRESS=(PROTOCOL=tcp)(HOST=10.10.10.10)(PORT=12345)) * establish * ORADB3 * 0
<txt>20-JUL-2015 07:58:38 * (CONNECT_DATA=(SID=ORADB4)(CID=(PROGRAM=)(HOST=__jdbc__)(USER=))) * (ADDRESS=(PROTOCOL=tcp)(HOST=10.10.10.10)(PORT=12345)) * establish * ORADB4 * 0
<txt>20-JUL-2015 08:01:09 * (CONNECT_DATA=(CID=(PROGRAM=JDBC Thin Client)(HOST=__jdbc__)(USER=ZAHIER))(SERVICE_NAME=ORADB6)(CID=(PROGRAM=JDBC Thin Client)(HOST=__jdbc__)(USER=ZAHIER))) * (ADDRESS=(PROTOCOL
=tcp)(HOST=10.10.10.10)(PORT=12345)) * establish * ORADB6 * 0[/pre]
I am working on Solaris 10 and tried using sed & awk (see below) to remove the text that I DO NOT want - but this is clearly inefficient.
Code:
grep HOST log.xml | sed 's/\*/ /g' | sed 's/(/ /g' | sed 's/)/ /g' | sed 's/<txt>/ /g' | sed 's/CONNECT_DATA= SERVICE_NAME=/ /g' | sed 's/CONNECT_DATA= SID=/ /g' | sed 's/CONNECT_DATA=/ /g' | sed 's/CID=/ /g' | sed 's/ADDRESS=/ /g' | sed 's/PROTOCOL=tcp/ /g' | sed 's/PORT=.*/ /g' | tr -s ' '
How do I extract just the fields that I need?