原文件: [root@system1 ~]# cat test test word test word test word test word test word word test word hello test word nihao test word nihao test word hi test word test word test word test word test word test word test word awk修改写入原文件后的文件: [root@system1 ~]# cat test test word test word test word test word test word word test word hello test word ni test word ni test word hi test word test word test word test word test word test word test word #注意:重定向符号后面的文件名需要加双引号 awk '{print > "file"}' file awk '$3!~/test/{sub("nihao","ni");print >"test"}' test sed写入原文件加 -i参数 sed -i 's/nihao/ni/g' test
linux awk把修改写入原文件中
最新推荐文章于 2023-05-15 21:06:57 发布