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

Ok so yeah. This uses grep to find a string in files in a directory and then executes sed to change a string in all of them. A beautiful super simple command…thx vasir!

Mario Loria is a builder of diverse infrastructure with modern workloads on both bare-metal and cloud platforms. He's traversed roles in system administration, network engineering, and DevOps. You can learn more about him here.