Recall & Review
beginner
What does the
tr command do in Linux?The
tr command translates or replaces characters from input text. It reads from standard input and writes to standard output.Click to reveal answer
beginner
How do you use
tr to change all lowercase letters to uppercase?Use
tr 'a-z' 'A-Z'. This replaces every lowercase letter with its uppercase version.Click to reveal answer
intermediate
What happens if the second set of characters in
tr is shorter than the first?The last character of the second set is repeated to match the length of the first set.
Click to reveal answer
beginner
How can you delete characters using
tr?Use the
-d option with the characters to delete. For example, tr -d 'aeiou' deletes vowels.Click to reveal answer
intermediate
Explain the use of
tr -s option.The
-s option squeezes repeated characters into one. For example, tr -s ' ' replaces multiple spaces with a single space.Click to reveal answer
What does
tr '0-9' ' ' do?✗ Incorrect
The command replaces all digits (0-9) with spaces.
Which option deletes characters in
tr?✗ Incorrect
The
-d option deletes specified characters.How do you convert uppercase letters to lowercase using
tr?✗ Incorrect
Use
tr 'A-Z' 'a-z' to convert uppercase to lowercase.What does
tr -s '\n' do?✗ Incorrect
The
-s option squeezes repeated newlines into a single newline.If the second set is shorter in
tr, what happens?✗ Incorrect
The last character of the second set repeats to match the first set's length.
Describe how to use
tr to replace all vowels with asterisks in a text.Think about specifying vowels as first set and '*' as second set.
You got /4 concepts.
Explain the difference between
tr -d and tr -s options with examples.Consider how each option changes the input text differently.
You got /3 concepts.