1.查找包含某字符串的命令,查询结果返回包含这个字符串的文件

grep -r "http:\/\/www.baidu.com\/test1\/test2\/35084580" /www/wwwroot/baidu.com

                            查找字符串内容                                                 查找路径

 2.查找包含某字符串内容并替换

sed -i "s/http:\/\/www.baidu.com\/test1\/test2\/35084580/http:\/\/www.baidu.com\/newpath1\/newpath2\/test/g" `grep -rl "http:\/\/www.baidu.com\/test1\/test2\/35084580" /www/wwwroot/baidu.com`

                       查找字符串内容                                                                    用来替换的内容                                                        查找字符串内容                                                                        查找路径 

 sed -i "s/查找字段/替换字段/g" 'grep -rl "查找字段" 路径'        

 

注意:"/"前需要加转义符"\"                 

 

相关文章:

  • 2021-12-14
  • 2022-12-23
  • 2022-12-23
  • 2021-09-09
  • 2022-02-28
  • 2021-09-06
  • 2021-09-14
  • 2022-12-23
猜你喜欢
  • 2021-07-26
  • 2021-05-14
  • 2022-12-23
  • 2022-01-07
  • 2021-12-11
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案