I am not very good at scritping, so AI needs hand on it.
I want to parse the data from the following output:
Actual output:
& lt; Connection-pool name = "name1" max-connection = "50" min-connection = "5" & gt; & Lt; Connection-factory factory-class = "oracle.jdbc.pool.OracleDataSource" user = "user1" password = "xxxx" url = "jdbc: oracle: thin: @ server1.domain.com: 1550: name 1" Commit- Record table name = "" & gt; & Lt; Connection-pool name = "name2" max-connection = "50" min-connection = "5" & gt; & Lt; Connection-factory factory-class = "oracle.jdbc.pool.OracleDataSource" user = "user2" password = "xxxx" url = "jdbc: oracle: thin: @ server2.domain.com: 1524: name 2" commit-record Table name = "" & gt; & Lt; Connection-pool name = "name3" max-connection = "15" mit-connection = "5" & gt; & Lt; Connection-factory factory-class = "oracle.jdbc.pool.OracleDataSource" user = "user3" password = "xxxx" url = "jdbc: oracle: thin: @ server3.domain.com: 1528: name 3" Commit- Record table name = "" & gt; & Lt; Connection-pool name = "name 4" initial-range = "1" max-connection = "10" m-connection = "1" number-cache-statement = "5" & gt; & Lt; Connection-factory factory-class = "oracle.jdbc.pool.OracleDataSource" user = "user4" password = "xxxx" url = "jdbc: oracle: thin: @ server4.domain.com: 1538: name 4" commit-record Table name = "" /> & Lt; Connection-pool name = "name 5" initial-range = "1" max-connection = "10" m-connection = "1" number-cache-statement = "5" & gt; & Lt; Connection-factory factory-class = "oracle.jdbc.pool.OracleDataSource" user = "user5" password = "xxxx" url = "jdbc: oracle: thin: @ // server5.domain.com:1537/name5" / & Gt;
desired output:
name = "name1" max-connection = "50" min-connection = "5" url = "jdbc: oracle : Slim: @ server1.domain.com: 1550: name1 "name =" name2 "max-connection =" 50 "min-connection =" 5 "url =" jdbc: oracle: thin: @ server2.domain.com: 1524 : Name2 "name =" name3 "max-connections =" 15 "min-connections =" 5 "url =" jdbc: oracle: thin: @ server3.domain.com: 1528: name 3 "name =" Name4 "max-connections =" 10 "min-connection =" 1 "url =" jdbc: oracle: thin: @ server4.domain.com: 1538: name 4 "name =" name 5 "max-connection =" 10 " M-connection = "1" URL = "Jdbc: oracle: thin: @ // server5.domain.com:1537/name5"
I would appreciate it if someone helped me I have BTW, because I can not install software on all production servers.
Thanks in advance!
Since it is not a valid XML, it can also be used:
sed -n '/ & lt; Connection-pool / {s ///; ? S / \ / \ & gt; $ //; S / \ (initial-limit \ | num-cached-statements \) = "[^"] * "// g; p} / & lt; connection-factory / s ///; s / \ / \? & Gt; $ //; s / \ (factory-class \ | user \ | password \ \ commit record-table-name \) = "[^"] * "// g; P} 'connections.log | Paste-D "- -
name =" name1 "max-connection =" 50 "min-connection =" 5 "url =" jdbc: oracle: thin: @ Server1.domain.com:1550:name1 "name =" name2 "max-connection =" 50 "min-connection =" 5 "url =" jdbc: oracle: thin: @ server2.domain.com: 1524: name2 " Name = "name3" max-connection = "15" mit-connection = "5" url = "jdbc: oracle: thin: @ server3.domain.com: 1528: name 3" name = "name" 4 "max-connection = "10" min-connections = "1" url = "jdbc: oracle: thin: @ server4.domain.com: 1538: name 4" name = "name 5" max-connection = "10" min-connection = " 1 "url =" jdbc: oracle: thin: @ / / server5.domain.com:1537/name5 "
Comments
Post a Comment