0
0
Linux CLIscripting~10 mins

tr (translate characters) in Linux CLI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
A'a-z' 'A-Z'
BA-Z a-z
C0-9 a-z
Da-z 0-9
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the order of character sets.
Using numbers instead of letters.
Forgetting to quote the character sets.
2fill in blank
medium

Complete 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'
Aa-z
B0-9
CA-Z
D[:alpha:]
Attempts:
3 left
💡 Hint
Common Mistakes
Deleting letters instead of digits.
Using uppercase letters as the set.
Not using the -d option.
3fill in blank
hard

Fix 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'
A" _"
B"_ "
C" " "_"
D"_" " "
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the order of characters.
Missing quotes around characters.
Using the wrong characters inside quotes.
4fill in blank
hard

Fill 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'
A-s ' '
B0-9
Ca-z
D-d ' '
Attempts:
3 left
💡 Hint
Common Mistakes
Using -d instead of -s for squeezing.
Deleting letters instead of digits.
Incorrect order of commands.
5fill in blank
hard

Fill 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'
A"a-z" "A-Z"
B0-9
C" " "_"
D"A-Z" "a-z"
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping uppercase and lowercase sets.
Forgetting to delete digits.
Incorrect quoting of characters.