Asked • 05/13/19

Replacing some characters in a string with another character?

I have a string like <!-- language: lang-none --> AxxBCyyyDEFzzLMN I want to replace all `x` and `y` and `z` with `_` so that the output is A_BC_DEF_LMN How to do that? I know a series of echo "$string" | tr 'x' '_' | tr 'y' '_' will work, but I want to do that in one go, without using pipes. EDIT: The following worked echo "$string" | tr '[xyz]' '_'

1 Expert Answer

By:

Benjamin M. answered • 02/04/21

Tutor
New to Wyzant

BS Computer Science, Linux classes and experience

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.