Awk/Sed: How to do a recursive find/replace of a string?

1

Awk/Sed: How to do a recursive find/replace of a string?

I am trying to replace specific text within several files (maybe around 200 files). Is there a way that I could this without having to replace the text manually.

I am actually trying to change the IPs in several httpd.conf, eg. 192.168.0.5 to 192.168.0.10. I have googled and some of the sites suggested using grep and awk, but no specific help was found by me.

Any help is greatly appreciated. Thanks.

Created by mamaykina 21 weeks 1 day ago – Made popular 21 weeks 1 day ago
Category:   Tags:

Answers to the above Question:

0

sed 's/original_string/new_string/' file1 file2 file3 ...

You can do

Code:
sed 's/original_string/new_string/' file1 file2 file3 ...

If the strings contain the character / you can use any other character
for delimiter.

On second thought this will send all the output to the screen.
So I guess you should do

Code:
sed 's/original_string/new_string/' file > tmp_file
mv tmp_file file

and repeat this for every file you want changed.

Read »
Created by ranipoojax 21 weeks 1 day ago
Category:   Tags: