linux批量替换文件内容命令

时间:2021-04-03 09:57:39

 把/usr/local/apache/conf下的所有conf的文件内容里含有【/usr/local/apache/htdocs】,改为【/data/wwwroot】。具体操作如下:

#sed -i “s/\/usr\/local\/apache\/htdocs/\/data\/wwwroot\/g” `find . -name “*.conf” | xargs grep “/usr/local/apache/htdocs” -rl`

或者

#find . -type f -exec sed -i ‘s#/usr/local/apache/htdocs#/data/wwwroot#g’ {} \;

本文出自 “爱在7元钱” 博客,请务必保留此出处http://oakcdrom.blog.51cto.com/1940330/1126885