
Benjamin M. answered 02/04/21
Tutor
New to Wyzant
BS Computer Science, Linux classes and experience
You can also use sed with multiple -e flags to accomplish this. If you're reading from a file, the -i flag will work in-place on the file, and you can provide it as an argument after the -e flags.
echo "$string" | sed -e 's/x/_/g' -e 's/y/_/g' -e 's/z/_/g'
Or in-place:
sed -i -e 's/x/_/g' -e 's/y/_/g' -e 's/z/_/g' filename.txt