nerdexam
CompTIA

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'.

GNU and Unix Commands

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)
  • A
    2% (1)
  • B
    8% (4)
  • C
    86% (44)
  • D
    4% (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'.

AHello 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.

Beoo

eoo represents only the deleted vowels themselves, not the remaining characters that tr outputs after deletion.

CHll WrldCorrect

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.

Deoo Hll Wrld

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

#tr command#character deletion#text processing#pipes

Community Discussion

No community discussion yet for this question.

Full LX0-103 Practice