Subscribe to RSS Subscribe to Comments

Alan Blaine Whitney

Recursive Find and Replace

At my job, I often need to recursivly find and replace certain strings. I always fumble around for the syntax, here is the syntax so I don’t forget

find ./ -type f -exec sed -i 's/ReplaceThis/WithThis/' {} \;

And you can add all of the custom stuff to find like name if you want, here is a real world example.

find ./ -name '*php' ! -name '.*' -exec sed -i 's/<noindex follow>/<!--sphider_noindex-->/' {} \;

No comments yet. Be the first.

Leave a reply

Based on FluidityTheme Redesigned by Kaushal Sheth Sponsored by Send Flowers