繁体   English   中英

如何使用通配符从linux中的行中删除特定模式

[英]How to delete a particular pattern from a line in linux using wildcard

如何使用通配符从linux中的行中删除特定模式?

test07cel20: ((host=test07db04.com,port=1832,community=public,(host=test07db02.com,port=1832,community=public),(host=172.186.100.63,port=162,community=public,type=ASR))

我想从上面的行中删除(host=172.186.100.63,port=162,community=public,type=ASR)172.186.100.63public172.186.100.63更改(我的意思是变量),所以寻找一些通配符方法。

此外,此模式将始终存在于行的末尾。 在某些情况下, type=ASR将为type=asr 因此,如果您有任何想法要涵盖删除模式host=*,port=162,community=*,type=ASR所有上述方案,请从一行中host=*,port=162,community=*,type=ASR 任何帮助是极大的赞赏。

预期产量是

(host=test07db04.com,port=1832,community=public),(host=test07db02.com,port=1832,community=public)

您的解决方案不必要地复杂化。 尝试这样的事情:

sed 's/,(host=[^(]*,port=162,[^(]*type=[Aa][Ss][Rr])//'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM