-
Notifications
You must be signed in to change notification settings - Fork 1.8k
SC2020
Joachim Ansorg edited this page Nov 12, 2021
·
5 revisions
echo 'hello world' | tr 'hello' 'goodbye'
echo 'hello world' | sed -e 's/hello/goodbye/g'
tr
is for tr
ansliteration, turning some characters into other characters. It doesn't match strings or words, only individual characters.
In this case, it transliterates h->g, e->o, l->d, o->y, resulting in the string "goddb wbrdd" instead of "goodbye world".
The solution is to use a tool that does string search and replace, such as sed.
None.