sed edit file in place

前端 未结 13 1705
忘掉有多难
忘掉有多难 2020-11-22 05:20

I am trying to find out if it is possible to edit a file in a single sed command without manually streaming the edited content into a new file and

13条回答
  •  名媛妹妹
    2020-11-22 05:52

    You didn't specify what shell you are using, but with zsh you could use the =( ) construct to achieve this. Something along the lines of:

    cp =(sed ... file; sync) file
    

    =( ) is similar to >( ) but creates a temporary file which is automatically deleted when cp terminates.

提交回复
热议问题