我试图运行此命令以从metasploit漏洞利用的目录grep漏洞利用MS- *
locate -r "\.rb$" | xargs grep "MSB" | grep metasploit | grep exploit | grep smb | awk '{print $3,$4}'
我得到这个结果:
grep:/usr/share/doc/ruby-http-parser.rb:是目录
'MS17-010'],
'MSB','MS03-049'
'MSB','MS04-007'],
'MSB','MS04-011'
'MSB','MS04-031'],
'MSB','MS05-039'
'MSB','MS06-025'
'MSB','MS06-025'
'MSB','MS06-040'
'MSB','MS06-066'],
'MSB','MS06-066'],
'MSB','MS06-070'
'MS07-029']
MS08-067),
'MSB','MS09-050'
我如何从每一行中删除此('MSB',')和('])
我需要这样的输出:
MS09-050
MS08-067
MS06-070
..
..
..
而且我还需要删除第一行(grep:/usr/share/doc/ruby-http-parser.rb:是目录)
最佳答案
locate -r "\.rb$" | xargs grep -s "MSB" | grep metasploit | grep exploit | grep smb | awk '{print $3,$4}'|sed "s/[,')]//g" |sed "s/MSB //g"|sed "s/]//g"
说明:
sed "s/[,')]//g"
-从每一行中删除,
'
和)
。sed "s/MSB //g"|sed "s/]//g"
-从每一行中删除MSB
。sed "s/]//g"
-删除]
xargs grep -s "MSB"
-grep中的-s
选项将禁止显示该输出的错误消息。关于linux - 在返回的输出bash中替换字符,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59609115/