how to write finding output to same file using awk command

前端 未结 6 1551
无人及你
无人及你 2021-01-31 15:46
awk \'/^nameserver/ && !modif { printf(\"nameserver 127.0.0.1\\n\"); modif=1 } {print}\' testfile.txt

It is displaying output but I want to wri

6条回答
  •  不要未来只要你来
    2021-01-31 16:25

    Had to make an account when seeing 'awk' and 'not possible' in one sentence. Here is an awk-only solution without creating a temporary file:

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

提交回复
热议问题