Save modifications in place with awk

前端 未结 8 1971
轻奢々
轻奢々 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:48

    @sudo_O has the right answer.

    This can't work:

    someprocess < file > file
    

    The shell performs the redirections before handing control over to someprocess (redirections). The > redirection will truncate the file to zero size (redirecting output). Therefore, by the time someprocess gets launched and wants to read from the file, there is no data for it to read.

提交回复
热议问题