How to use sed output to overwrite existin file

In this article let’s discuss about How to use sed output to overwrite existin file. Let’s go through the following methods without any delay.

Method 1:

sed -i 's/old-text/new-text/g' input.txt

If you are facing any issues with the above approach then try the alternative that is given below. It may look similar by have a try!

Method 2 :

sed -i 's/foo/bar/g' hello.txt

Hope the above solution works.

Realted Posts : How to assign variable with sed not working