I have tnsnames.ora file like
DB_CONNECTION1=
(description=
(address=
(protocol=tcp)
(host=myhost1.mydomain.com)
(port=1234)
)
(connect_data=
(sid=ABCD)
(sdu=4321)
)
DB_CONNECTION2=
(description=
(address=
(protocol=tcp)
(host=myhost2.mydomain.com)
(port=1234)
)
(connect_data=
(sid=ABCD)
(sdu=4321)
)
What regular expression do i need to use to extract the value myhost from the key host.
Ouput should be
myhost1
myhost2
As grep prints the whole line, you could do it in steps like:
grep "(host=" tnsnames.ora | cut -f 2 -d '=' | cut -f 1 -d '.'
To break it down:
You can execute the chain of commands to any point, to see the intermediate result, like:
grep "(host=" tnsnames.ora | cut -f 2 -d '='
Would give you:
myhost1.mydomain.com)
myhost2.mydomain.com)
That way it's easy to build your set of commands to do this type of thing.