replacing all entries of <oldowner> with <newowner> in multiple php files

NeghVar

2[H]4U
Joined
May 1, 2003
Messages
2,473
Ok, my employer bought out another company. As we are doing some changes to the website and intranet website. Every php file has the string copyright old.owner@oldcompany.com . We want to change this to new.owner@newcompany.com.

Is there a command in Centos 7 cli which will replace the old string with the new string in all php files in /var/www recursively?
 

modi123

Supreme [H]ardness
Joined
Sep 6, 2006
Messages
5,757
If I remember my linus right you can use 'find' and pipe that into a 'sed' command.
 

defaultluser

[H]F Junkie
Joined
Jan 14, 2006
Messages
13,501
Screw command line bs and pipes, that's what modern text editors are for :D

Ultraedit can easily do this. Search->Replace In Files. I would imagine any other Dev Environment could do the same.
 

grasshoppa

2[H]4U
Joined
Jun 18, 2017
Messages
3,671
If I remember my linus right you can use 'find' and pipe that into a 'sed' command.
find /var/www -type f -exec sed -i 's/old.owner@oldcompany.com/new.owner@newcompany.com/g' {} \;

Or go the GUI editor route. It's whatever you're most comfortable with.
 
Top