Replace string within file contents

后端 未结 8 1767
不知归路
不知归路 2020-12-01 00:28

How can I open a file, Stud.txt, and then replace any occurences of \"A\" with \"Orange\"?

8条回答
  •  佛祖请我去吃肉
    2020-12-01 01:20

    If you are on linux and just want to replace the word dog with catyou can do:

    text.txt:

    Hi, i am a dog and dog's are awesome, i love dogs! dog dog dogs!
    

    Linux Command:

    sed -i 's/dog/cat/g' test.txt
    

    Output:

    Hi, i am a cat and cat's are awesome, i love cats! cat cat cats!
    

    Original Post: https://askubuntu.com/questions/20414/find-and-replace-text-within-a-file-using-commands

提交回复
热议问题