美文网首页
用GREP查找或替换多个文件中的字符串

用GREP查找或替换多个文件中的字符串

作者: JerodYan | 来源:发表于2014-11-25 15:30 被阅读55次

查找多个XML文件中的‘Hello World’

 grep -rnw '/dir/dir/dir' \
          -e 'hello world' \
         --include=\*.xml \
         --color

查找并替换多个文件中的字符串

 grep -rl 'hello world' /dir/dir/dir/ | xargs \
      sed -i 's/hello/goodbye/g'

其中,-r 表示递归,-l 表示只显示文件名。

相关文章

网友评论

      本文标题:用GREP查找或替换多个文件中的字符串

      本文链接:https://www.haomeiwen.com/subject/niiwtttx.html