All Linux HowTo's

Find and Replace in multiple directories

This article explains how to search for files with a string and replace that string with another string.

cd /home
find ./ -type f -exec sed -i -e 's/FromThis/ToThis/g' {} \;

The above will search through the /home directories and replace any occurrence in any file of “FromThis” with “ToThis”.

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.