0
0
Linux CLIscripting~20 mins

tr (translate characters) in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
tr Command Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
What is the output of this tr command?
Given the input string hello world, what is the output of the command echo 'hello world' | tr 'a-z' 'A-Z'?
Linux CLI
echo 'hello world' | tr 'a-z' 'A-Z'
Ahello world
BHELLO WORLD
CHELLO world
DError: invalid range
Attempts:
2 left
💡 Hint
The tr command can convert lowercase letters to uppercase by specifying ranges.
💻 Command Output
intermediate
1:30remaining
What does this tr command output?
What is the output of echo '123-456-7890' | tr -d '-'?
Linux CLI
echo '123-456-7890' | tr -d '-'
A1234567890
B123 456 7890
CError: invalid option
D123-456-7890
Attempts:
2 left
💡 Hint
The -d option deletes characters specified in the set.
💻 Command Output
advanced
1:30remaining
What is the output of this tr command with squeeze?
Given the input echo 'aaabbbcccaaa' | tr -s 'a', what is the output?
Linux CLI
echo 'aaabbbcccaaa' | tr -s 'a'
Aabbbccc
Babbbcccaa
Cabbbccca
DError: invalid option
Attempts:
2 left
💡 Hint
The -s option squeezes repeated characters in the set into one.
💻 Command Output
advanced
1:30remaining
What error does this tr command produce?
What error message results from running echo 'test' | tr 'a-z' 'A-Z' '0-9'?
Linux CLI
echo 'test' | tr 'a-z' 'A-Z' '0-9'
Atr: extra operand '0-9'
Btest
CTEST
DError: invalid range
Attempts:
2 left
💡 Hint
The tr command accepts only two sets of characters for translation.
🚀 Application
expert
2:00remaining
How many characters are in the output after this tr command?
Given the input string echo 'aabbccddeeff' | tr -d 'bdf', how many characters does the output contain?
Linux CLI
echo 'aabbccddeeff' | tr -d 'bdf'
A8
B9
C12
D6
Attempts:
2 left
💡 Hint
Count the characters after deleting all 'b', 'd', and 'f'.