Find & Replace in Files
I understand I can use sed to find and replace data such as follows:
grep -r -l -e 'something1' /home/user/public_html/* | xargs sed -i 's/something1/something2/g'
But how do I replace string that contains forward slashes?
For example, how would I replace the following?
FIND: example.com/~user/
REPLACE: example.org/
-
Hi, To use the forward slashes as it is, you have to escape it with the backward slash.. "\/" like this.. 0 -
Hello, You may also find the following third-party URL helpful: sed find replace string with special characters Thank you. 0
Please sign in to leave a comment.
Comments
2 comments