sed -e "s/https:\/\/raw.githubusercontent.com\/wolfdan666\/BlogPic\/master\//https:\/\/gitee.com\/wolfdan\/BlogPic\/raw\/master\//g" ARSTB打卡第44周-44-521.md
sed -i "s/https:\/\/raw.githubusercontent.com\/wolfdan666\/BlogPic\/master\//https:\/\/gitee.com\/wolfdan\/BlogPic\/raw\/master\//g" ARSTB打卡 第44周-44-521.md
解读
这里就是上面的脚本把-e改成-i
结果展示
sed修改文件,git查看差异
文件批处理
操作前请备份,或者有git仓库,可以回滚
测试find
1
for n in `find . -name "*.md"`;doecho$n;done
编写脚本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
wolfdan@wolfdan-PC $ vim chlink.sh wolfdan@wolfdan-PC $ cat chlink.sh #!bin/bash
for n in `find . -name "*.md"` do ((sum++)) sed -i "s/https:\/\/raw.githubusercontent.com\/wolfdan666\/BlogPic\/master\//https:\/\/gitee.com\/wolfdan\/BlogPic\/raw\/master\//g"$n done
for n in `find . -name "*.md"` do ((sum++)) #sed -i "s/https:\/\/raw.githubusercontent.com\/wolfdan666\/BlogPic\/master\//https:\/\/gitee.com\/wolfdan\/BlogPic\/raw\/master\//g" $n sed -i "s/https:\/\/gitee.com\/wolfdan\/BlogPic\/raw\/master/https:\/\/www.wolfdan.cn\/img/g"$n done
for n in `find . -name "*.md"` do ((sum++)) #sed -i "s/https:\/\/raw.githubusercontent.com\/wolfdan666\/BlogPic\/master\//https:\/\/gitee.com\/wolfdan\/BlogPic\/raw\/master\//g" $n #sed -i "s/https:\/\/gitee.com\/wolfdan\/BlogPic\/raw\/master/https:\/\/www.wolfdan.cn\/img/g" $n sed -i "s/https:\/\/www.wolfdan.cn\/img/https:\/\/cdn.jsdelivr.net\/gh\/wolfdan666\/BlogPic/g"$n done echo"操作了{$sum}个文件" echo"请仔细核查,建议使用VScode的git工具查看更改差异更香"