LFCS · Question #734
What is the output of the following command? echo "Hello World" | tr -d aieou
The correct answer is C. Hll Wrld. The tr -d command deletes specified characters from its input, thus removing all lowercase vowels from 'Hello World'.
Question
Options
- AHello World
- Beoo
- CHll Wrld
- Deoo Hll Wrld
How the community answered
(29 responses)- A3% (1)
- B10% (3)
- C79% (23)
- D7% (2)
Why each option
The `tr -d` command deletes specified characters from its input, thus removing all lowercase vowels from 'Hello World'.
`Hello World` would be the output if no transformation occurred, but `tr -d aieou` specifically removes characters.
`eoo` would only be the output if `tr` was designed to extract vowels, which is not the function of `-d` (delete).
The `tr` command with the `-d` option deletes characters specified in the second argument from the input. Here, `aieou` specifies that all occurrences of lowercase 'a', 'i', 'e', 'o', and 'u' should be removed from 'Hello World', resulting in 'Hll Wrld'.
`eoo Hll Wrld` is a nonsensical combination of deleted and remaining characters, as `tr` processes the entire input stream, not parts of it separately.
Concept tested: Linux `tr` command character deletion
Source: https://man7.org/linux/man-pages/man1/tr.1.html
Topics
Community Discussion
No community discussion yet for this question.