Find and Replace string in all files

From brokenpoet.org wiki

Used to search through all files forward of the directory you are in and replace things. Does not play with with files or directories that have spaces in the names:

export IFS=$'\n';grep -lr -e 'oldwords' .|xargs sed -i 's/oldwords/newwords/g'

For example

export IFS=$'\n';grep -lr -e '/var/www/vhosts/domain.com/httpdocs' .| xargs sed -i 's/\/var\/www\/vhosts\/domain.com\/httpdocs/\/home\/username\/public_html/g'

Personal tools