Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to translate all lowercase letters to uppercase using tr.
Linux CLI
echo "hello world" | tr [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the order of character sets.
Using numbers instead of letters.
Forgetting to quote the character sets.
✗ Incorrect
The
tr command translates characters from the first set to the second set. To convert lowercase to uppercase, use tr 'a-z' 'A-Z'.2fill in blank
mediumComplete the code to delete all digits from the input using tr.
Linux CLI
echo "abc123def456" | tr -d [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Deleting letters instead of digits.
Using uppercase letters as the set.
Not using the
-d option.✗ Incorrect
The
-d option deletes characters. To delete digits, use 0-9.3fill in blank
hardFix the error in the code to replace all spaces with underscores using tr.
Linux CLI
echo "hello world" | tr [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the order of characters.
Missing quotes around characters.
Using the wrong characters inside quotes.
✗ Incorrect
The correct syntax is
tr ' ' '_' to replace spaces with underscores. Quotes are needed around each character set.4fill in blank
hardFill both blanks to create a command that squeezes multiple spaces into one space and then deletes all digits.
Linux CLI
echo "a b c123" | tr [1] | tr -d [2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
-d instead of -s for squeezing.Deleting letters instead of digits.
Incorrect order of commands.
✗ Incorrect
Use
tr -s ' ' to squeeze spaces and tr -d 0-9 to delete digits.5fill in blank
hardFill all three blanks to create a command that converts lowercase to uppercase, deletes digits, and replaces spaces with underscores.
Linux CLI
echo "hello 123 world" | tr [1] | tr -d [2] | tr [3]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping uppercase and lowercase sets.
Forgetting to delete digits.
Incorrect quoting of characters.
✗ Incorrect
First, convert lowercase to uppercase with
tr 'a-z' 'A-Z'. Then delete digits with tr -d 0-9. Finally, replace spaces with underscores using tr ' ' '_'.