#目标路径
path=./static/js
#要替换的字符
old=cjj-api
#新的字符
new=llj-api
#grep命令获取包含指定old字符的文件名称数组
files=($(grep -rl $old $path))
# 使用 for 循环和索引访问数组元素
for index in "${!files[@]}"; do
echo "Index: $index, Fruit: ${files[$index]}"
sed -i "s/$old/$new/g" ${files[$index]}
done
echo "====finished==="
Linux 命令获取指定路径下的包含特定字符的文件名称,并SED命令全替换
于 2023-07-11 11:19:38 首次发布