企業案例:查找當前目錄下全部文件,並把文件中的https://www.cnblogs.com/zhaokang2019/字符串替換成https://www.cnblogs.com/guobaoyan2019/blog
方法1:字符串
建立實戰數據:test
echo https://www.cnblogs.com/zhaokang2019/>a
echo https://www.cnblogs.com/zhaokang2019/>bsed
echo https://www.cnblogs.com/zhaokang2019/>c方法
echo https://www.cnblogs.com/zhaokang2019/>a.txt數據
查看數據源:文件
[root@zhaokang test]# find . -type f |xargs cat
https://www.cnblogs.com/zhaokang2019/
https://www.cnblogs.com/zhaokang2019/
https://www.cnblogs.com/zhaokang2019/
https://www.cnblogs.com/zhaokang2019/co
經過find命令查找,而後經過管道,xargs 調用sed命令完成替換。字符
find . -type f |xargs sed -i 's#https://www.cnblogs.com/zhaokang2019/#https://www.cnblogs.com/guobaoyan2019/#g'ps
替換後,查看數據:
[root@zhaokang test]# find . -type f |xargs cathttps://www.cnblogs.com/guobaoyan2019/https://www.cnblogs.com/guobaoyan2019/https://www.cnblogs.com/guobaoyan2019/https://www.cnblogs.com/guobaoyan2019/