rxqvra
Last Updated: February 25, 2016
·
1.031K
· rhumlover
317ab34676c3df82341d883b9e14e294

Grep and replace text in files

Linux

grep -rl matchstring somedir/ | xargs sed -i 's/string1/string2/g'

MacOS

grep -rl matchstring somedir/ | xargs sed -i '' 's/string1/string2/g'

@see http://stackoverflow.com/a/4247319

Source: http://vasir.net/blog/ubuntu/replace_string_in_multiple_files

Say Thanks
Respond
Filed Under