LX0-103 · Question #134
What is the output of the following command? echo "Hello World" | tr -d aieou
The correct answer is C. Hll Wrld. The tr -d option deletes every occurrence of the listed characters from input, so all lowercase vowels are removed from 'Hello World'.
Question
What is the output of the following command? echo "Hello World" | tr -d aieou
Options
- AHello World
- Beoo
- CHll Wrld
- Deoo Hll Wrld
How the community answered
(51 responses)- A2% (1)
- B8% (4)
- C86% (44)
- D4% (2)
Why each option
The tr -d option deletes every occurrence of the listed characters from input, so all lowercase vowels are removed from 'Hello World'.
Hello World would be the output only if no characters were deleted, but tr -d aieou explicitly removes lowercase vowels present in the string.
eoo represents only the deleted vowels themselves, not the remaining characters that tr outputs after deletion.
tr -d aieou instructs tr to delete any character that appears in the set {a, i, e, o, u}. Applying this to 'Hello World' removes 'e' (from Hello), 'o' (from Hello), and 'o' (from World), leaving 'Hll Wrld'. Uppercase letters and spaces are not in the delete set, so they are preserved.
eoo Hll Wrld incorrectly combines the deleted characters with the remaining output; tr outputs only the surviving characters, not both.
Concept tested: tr command character deletion with -d flag
Source: https://www.gnu.org/software/coreutils/manual/coreutils.html#tr-invocation
Topics
Community Discussion
No community discussion yet for this question.