shell脚本中修改文件的内容

时间:2021-03-27 12:20:52   收藏:0   阅读:22

1、修改某文件中的内容:将oldstring修改为newstring

      sed -i "s/oldstring/newstring/g" test.txt 

如果将oldstringXXX修改为newstring:

    sed -i "s/oldstring*/newstring/g" test.txt

 

2、将某个目录中所有含有oldstring字符串的文件中的oldstring修改为newstring

    sed -i "s/oldstring/newstring/g" `grep "jack" -rl ./`



原文:https://www.cnblogs.com/surplus/p/14585194.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!