Modify conf file using shell script

I have a default conf file that we use over and over in our projects. And for each project, the file must be changed. More than once, one person who edited the conf file made multiple errors.

So, I wanted to write a shell script that can be called to modify the conf file.

But, being new to shell scripts, I don't know how to do this. What is the appropriate * nix tool to open a text file, find a line, replace it with another, and then close the text file.

Thank! Eric

+5
source share
3 answers

You should look at the sed command. It allows you to edit the stream (for example, a file) so that you can replace, insert, delete text.

http://www.grymoire.com/Unix/Sed.html

+3

, sed .

(-i):

sed -i 's/Release Two/Testing Beta/g' /path/to/file.txt

, Release Two, - . , / g , , ( .) ,

sed -iBACKUP_SUFFIX ...
+10

All Articles