Redirect output from sed 's/c/d/' myFile to myFile

后端 未结 10 844
暖寄归人
暖寄归人 2020-12-09 10:15

I am using sed in a script to do a replace and I want to have the replaced file overwrite the file. Normally I think that you would use this:

% sed -i \'s/c         


        
10条回答
  •  死守一世寂寞
    2020-12-09 10:40

    A lot of answers, but none of them is correct. Here is the correct and simplest one:

    $ echo "111 222 333" > file.txt
    $ sed -i -s s/222/444/ file.txt 
    $ cat file.txt
    111 444 333
    $ 
    

提交回复
热议问题