使用 grep 解析 tnsnames.ora 以提取主机名减去域
我有 tnsnames.ora 文件,例如
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)
)
我需要使用什么正则表达式从密钥主机中提取值 myhost 。
Ouput should be
myhost1
myhost2
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当 grep 打印整行时,您可以按照如下步骤进行操作:
要将其分解:
您可以执行命令链到任何点,以查看中间结果,例如:
会给您:
这样就可以轻松构建命令集来执行此类操作。
As grep prints the whole line, you could do it in steps like:
To break it down:
You can execute the chain of commands to any point, to see the intermediate result, like:
Would give you:
That way it's easy to build your set of commands to do this type of thing.