Save modifications in place with awk

前端 未结 8 1970
轻奢々
轻奢々 2020-11-21 23:32

I am learning awk and I would like to know if there is an option to write changes to file, similar to sed where I would use -i option

8条回答
  •  孤独总比滥情好
    2020-11-21 23:57

    In case you want an awk-only solution without creating a temporary file and usable with version!=(gawk 4.1.0):

    awk '{a[b++]=$0} END {for(c=0;c<=b;c++)print a[c]>ARGV[1]}' file
    

提交回复
热议问题