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
Written by Thomas LE JEUNE
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Terminal
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#