Q:

How to edit a string in multiple files [bash]?

I have a bunch of git project that mostly have similar folder structure but not always.
config of these git project is what interests me, most configs can be found in
/var/www/*/www/.git/config

In the config files, a lot of projects have an IP address set in the remote origin section instead of a domain.
Now I want to edit all .git/configs that have a string IP with a domain (or another IP) all at once.
I tried with sed and gave it the /var/www/*/www/.git/config as a file but that doesn't work because sed doesn't edit the file and save it, it only outputs the change. I need something that will go into every .git/config and replace a string and immediately save the file.
Possible a bash script is in order for this.

A:

use -i option with sed this will update the file

-i[SUFFIX], --in-place[=SUFFIX] edit files in place (makes backup if extension supplied). The default operation mode is to break symbolic
and hard links. This can be changed with --follow-symlinks and --copy.

Ref : https://linux.die.net/man/1/sed

