英文:
Replacing chars in returned output bash
问题
I can help you with the translation:
我可以帮助您进行翻译:
im tryng to run this command to grep the exploit MS-* from metasploit exploit's dir
我尝试运行此命令来从metasploit exploit目录中查找MS-*的漏洞
locate -r ".rb$" | xargs grep "MSB" | grep metasploit | grep exploit | grep smb | awk '{print $3,$4}'
找到 -r ".rb$" | xargs grep "MSB" | grep metasploit | grep exploit | grep smb | awk '{print $3,$4}'
i got this result :
我得到了这个结果:
> grep: /usr/share/doc/ruby-http-parser.rb: Is a directory
> grep:/usr/share/doc/ruby-http-parser.rb:是一个目录
> 'MS17-010'],
> 'MS17-010'],
> 'MSB', 'MS03-049'
> 'MSB', 'MS03-049'
> 'MSB', 'MS04-007'],
> 'MSB', 'MS04-007'],
> 'MSB', 'MS04-011'
> 'MSB', 'MS04-011'
> 'MSB', 'MS04-031'],
> 'MSB', 'MS04-031'],
> 'MSB', 'MS05-039'
> 'MSB', 'MS05-039'
> 'MSB', 'MS06-025'
> 'MSB', 'MS06-025'
> 'MSB', 'MS06-040'
> 'MSB', 'MS06-040'],
> 'MSB', 'MS06-066'],
> 'MSB', 'MS06-066'],
> 'MSB', 'MS06-070'
> 'MSB', 'MS06-070'],
> 'MS07-029']
> 'MS07-029']
> MS08-067),
> MS08-067),
> 'MSB', 'MS09-050'
> 'MSB', 'MS09-050'
how i can remove this ('MSB', ' ) and ('])from each line
如何删除每行中的('MSB',')和('])?
i need output like this :
我需要类似这样的输出:
> MS09-050
> MS09-050
> MS08-067
> MS08-067
> MS06-070
> MS06-070
and also i need to remove the first line ( grep: /usr/share/doc/ruby-http-parser.rb: Is a directory )
我还需要删除第一行(grep:/usr/share/doc/ruby-http-parser.rb:是一个目录)
英文:
im tryng to run this command to grep the exploit MS-* from metasploit exploit's dir
locate -r "\.rb$" | xargs grep "MSB" | grep metasploit | grep exploit | grep smb | awk '{print $3,$4}'
i got this result :
> grep: /usr/share/doc/ruby-http-parser.rb: Is a directory
>
> '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'
how i can remove this ('MSB', ' ) and ('])from each line
i need output like this :
> MS09-050
>
> MS08-067
>
> MS06-070
>
> ..
>
> ..
>
> ..
and also i need to remove the first line ( grep: /usr/share/doc/ruby-http-parser.rb: Is a directory )
答案1
得分: 0
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"
英文:
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"
Explanation:
-
sed "s/[,')]//g"
- removes,
'
and)
from each line. -
sed "s/MSB //g"|sed "s/]//g"
- removesMSB
from each line. -
sed "s/]//g"
- removes]
-
xargs grep -s "MSB"
- the-s
option in grep will suppress error messages for that output.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论