如何使用通配符从 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.63
, public
将逐个改变(我的意思是变量),所以寻找一些通配符方法。
此外,该模式将始终存在于行尾。在某些情况下,type=ASR
将是 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])//'
关于linux - 如何使用通配符从 linux 中的一行中删除特定模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41820574/