Recall & Review
beginner
What does the
tr command do in bash scripting?The
tr command translates or deletes characters from input. It is used to transform characters, like changing lowercase letters to uppercase.Click to reveal answer
beginner
How do you use
tr to convert all lowercase letters to uppercase?Use
tr 'a-z' 'A-Z'. It replaces every lowercase letter with its uppercase equivalent.Click to reveal answer
intermediate
What happens if the input contains characters not in the first set of
tr?Characters not in the first set are passed through unchanged.
tr only transforms characters it matches in the first set.Click to reveal answer
intermediate
How can you delete characters using
tr?Use the
-d option with the characters to delete. For example, tr -d 'aeiou' deletes all vowels from the input.Click to reveal answer
beginner
Explain the difference between
tr 'a-z' 'A-Z' and tr 'A-Z' 'a-z'.tr 'a-z' 'A-Z' converts lowercase letters to uppercase. tr 'A-Z' 'a-z' converts uppercase letters to lowercase.Click to reveal answer
Which
tr command converts all lowercase letters to uppercase?✗ Incorrect
The command
tr 'a-z' 'A-Z' replaces lowercase letters with uppercase letters.What does
tr -d 'aeiou' do?✗ Incorrect
The
-d option deletes specified characters, so vowels are removed.If input contains digits and you run
tr 'a-z' 'A-Z', what happens to digits?✗ Incorrect
Characters not in the first set are passed through unchanged.
Which command deletes all spaces from input?
✗ Incorrect
tr -d ' ' deletes all space characters.What is the output of
echo 'Hello123' | tr 'A-Z' 'a-z'?✗ Incorrect
This converts uppercase letters to lowercase, digits remain unchanged.
Describe how to use
tr to change all lowercase letters in a text to uppercase.Think about replacing one set of characters with another.
You got /4 concepts.
Explain how to remove specific characters from input using
tr.Deleting means removing characters completely.
You got /4 concepts.