sed edit file in place

前端 未结 13 2051
忘掉有多难
忘掉有多难 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:57

    Like Moneypenny said in Skyfall: "Sometimes the old ways are best." Kincade said something similar later on.

    $ printf ',s/false/true/g\nw\n' | ed {YourFileHere}
    

    Happy editing in place. Added '\nw\n' to write the file. Apologies for delay answering request.

提交回复
热议问题