how to write finding output to same file using awk command

前端 未结 6 1549
无人及你
无人及你 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:17

    You can also use sponge from moreutils.

    For example

    awk '!a[$0]++' file|sponge file
    

    removes duplicate lines and

     awk '{$2=10*$2}1' file|sponge file
    

    multiplies the second column by 10.

提交回复
热议问题