When I run the command $ echo "Hello, World!" | tr -c 'aeiou' '*', the terminal returns *e**o***o*****. There are only 4 characters after the last vowel o, so tr should replace each of them with a * to return *e**o***o****, but it is adding one more * to the output string which seems illogical to me.
I also tried $ echo "o!" | tr -c 'aeiou' '*', but still it is returning o** instead of o*.
Can anyone please help me understand the reason?
echo 'o!'outputs three characters:o,!and a Line Feed.printf 'o!'only outputs the first two.Alternatively, you could preserve the Line Feed using
tr -c 'aeiou\n' '*'(at least on my system).