How To Find & Replace Text within Multiple Files & Directories with Grep & Sed


 You would like to replace the following URL within ' index.html ' of all cPanel Users;




 First we have a look at ' index.html ' to see if we can make the replace more specific.

# vi /home/foouser/public_html/index.html

We find one instance that we can use ' action=" '

# grep -rl 'action="' ./ | xargs sed -i 's#action=""'

+ This will search for the string ' action=" ' in all files relative ( ./ ) to the current directory. It will then replace ' action=" ' with ' action=" ' for each occurrence of the string in every file.

Have more questions? Submit a request