In-place-style transform with awk awk

Global substitution and write back to same file

awk '{gsub(/foo/, "bar"); print}' input.txt > tmp && mv tmp input.txt