Table of Contents
In this post, we will see how to replace String in file using sed in linux.
Problem
How to find and replace "Text1" with "Text2" using sed command in linux.
Solution
Sed stands for stream editor.It reads the file and modifies the file as provided by list of sed command.By default, input is written on the screen but you can update the file as well using -i option.
Here is simple command to replace string in file.
sed -i -e ‘s/old-string/new-string/g’ sample.txt
Was this post helpful?
Let us know if this post was helpful. Feedbacks are monitored on daily basis. Please do provide feedback as that\'s the only way to improve.