shell 遍历目录下后缀名为.html的文件,并替换文件中内容

来源:互联网 发布:淘宝网恐龙玩具 编辑:程序博客网 时间:2024/05/15 21:28

1、shell查找 .html文件,例:

find /usr/local/guotom/webapps/ZingMH/nodeJs/tpls/views/ -type f -name '*.html'

2、替换方法

sed -i "s/邀请/呵呵/g"【将邀请替换为呵呵】

3、查找并替换

find /usr/local/guotom/webapps/ZingMH/nodeJs/tpls/views/ -type f -name '*.html'|xargs sed -i "s/邀请/呵呵/g"【查找/usr/local/guotom/webapps/ZingMH/nodeJs/tpls/views/目录下所有html文件中的内容并将文件中邀请替换为呵呵】

阅读全文
0 0