I am confused regarding the way -s, -t, and -c options work in the tr command. When I do
echo I am a good boy | tr good bad
I get the output:
I am a bddd bdy
This is quite understandable, since o is repeated in good. The last possible change in place of o is d, and hence the output.
Now when I do
echo I am a good boy | tr -s good bad
the output is
I am a bd bdy
The -s option is supposed to squeeze every repeated occurence of each character in set 1 into a single occurence and then change each character in set 1 into the corresponding character in set 2 which is in the same position.
So it should have been
I am a bad bay.
Why the change?
Moreover, when I do
echo I am a good boy | tr -c good bad
I get dddddddgoodddodd
How does the -c option work for tr, referring to this example?
And finally: how to change myself from a good boy to a bad boy.... :) :P That is,
echo I am a good boy | tr <something> gives me the output as: I am a bad boy.