Reputation: 73
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' {} \;
Now I need to replace the keyword "Rename" with "XYZ" leaving the rest of text in each file intact.
Ideas?
Upvotes: 0
Views: 33
Reputation: 15273
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.
Upvotes: 2