Challenge - 5 Problems
tr Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Output of tr command with character deletion
What is the output of this command?
echo "hello world" | tr -d 'aeiou'
Bash Scripting
echo "hello world" | tr -d 'aeiou'
Attempts:
2 left
💡 Hint
The -d option deletes characters specified.
✗ Incorrect
The command deletes all vowels from the input string, leaving only consonants and spaces.
💻 Command Output
intermediate2:00remaining
Transform lowercase to uppercase using tr
What is the output of this command?
echo "bash scripting" | tr 'a-z' 'A-Z'
Bash Scripting
echo "bash scripting" | tr 'a-z' 'A-Z'
Attempts:
2 left
💡 Hint
tr replaces characters from the first set with the second set.
✗ Incorrect
All lowercase letters are converted to uppercase letters.
💻 Command Output
advanced2:00remaining
Output of tr with complement and squeeze
What is the output of this command?
echo "aaabbbccc111222333" | tr -cs 'a-z' $'\n'
Bash Scripting
echo "aaabbbccc111222333" | tr -cs 'a-z' $'\n'
Attempts:
2 left
💡 Hint
The -c option complements the set; -s squeezes repeated characters.
✗ Incorrect
The command replaces all characters except lowercase letters with newlines and squeezes repeats, resulting in each group of letters on a new line.
💻 Command Output
advanced2:00remaining
Effect of tr with overlapping sets
What is the output of this command?
echo "123abc" | tr '1-3a-c' 'x-z1-3'
Bash Scripting
echo "123abc" | tr '1-3a-c' 'x-z1-3'
Attempts:
2 left
💡 Hint
Characters in the first set are replaced by corresponding characters in the second set.
✗ Incorrect
Digits 1-3 map to x-z and letters a-c map to 1-3, so '123abc' becomes 'xyz123'.
💻 Command Output
expert3:00remaining
Count unique characters after tr transformation
What is the number of unique characters in the output of this command?
echo "Hello World! 123" | tr 'A-Za-z' 'n-za-mN-ZA-M' | tr -d ' ' | tr -d '!' | fold -w1 | sort -u | wc -l
Bash Scripting
echo "Hello World! 123" | tr 'A-Za-z' 'n-za-mN-ZA-M' | tr -d ' ' | tr -d '!' | fold -w1 | sort -u | wc -l
Attempts:
2 left
💡 Hint
The first tr applies ROT13 cipher, then spaces and '!' are removed, unique characters counted.
✗ Incorrect
ROT13 transforms letters, digits remain unchanged. After removing spaces and '!', counting unique characters yields 10.