【shell】 IFS 遍历某个目录下的所有文件,并进行某种处理

#!/bin/bash

old_branch=$1
new_branch=$2

echo $PWD
# 查找当前目录及子目录下的所有.xml文件

#for file in *.xml; do
#       echo "=====修改${file}===="
#       sed -i "s/revision=\"$old_branch\"/revision=\"$new_branch\"/g" $file
#       echo ""
#       echo -e "\033[31m修改完毕\033[0m"
#done

find . -type f -name "*.xml" -print0 |
while IFS= read -r -d '' file; do
    echo "=====修改${file}===="
    sed -i "s/revision=\"$old_branch\"/revision=\"$new_branch\"/g" $file
    echo ""
    echo -e "\033[31m修改完毕\033[0m"
done
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容