0

I need to find all files containing certain text inside my project directory. This includes sub-directories.

I've managed to find all the files:

find . -type f -exec grep -H 'Rename' {} \;

enter image description here

Now I need to replace the keyword "Rename" with "XYZ" leaving the rest of text in each file intact.

Ideas?

1 Answer 1

2

sed instead of grep.

find . -type f -exec sed -i 's/Rename/XYZ/g' {} \;

grep already scans all the lines of every file, so you aren't losing anything. This just makes the change when it finds it, instead of printing out the line.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.