0
0
Bash Scriptingscripting~20 mins

Uppercase and lowercase conversion in Bash Scripting - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Uppercase & Lowercase 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 Bash command?
Consider the following command that converts a string to uppercase. What will it output?
Bash Scripting
echo "hello World" | tr '[:lower:]' '[:upper:]'
Ahello World
BHELLO WORLD
CHello World
DHELLO world
Attempts:
2 left
💡 Hint
The tr command replaces characters from one set to another.
💻 Command Output
intermediate
1:30remaining
What is the output of this Bash command?
What will this command output when converting a string to lowercase?
Bash Scripting
echo "BASH SCRIPTING" | tr '[:upper:]' '[:lower:]'
Abash scripting
BBASH SCRIPTING
CBash Scripting
Dbash SCRIPTING
Attempts:
2 left
💡 Hint
The tr command changes uppercase letters to lowercase letters.
📝 Syntax
advanced
2:00remaining
Which option correctly converts a variable to uppercase in Bash?
Given a variable name VAR="hello", which command correctly converts its value to uppercase?
Bash Scripting
VAR="hello"
Aecho ${VAR^^:}
Becho ${VAR^^^}
Cecho ${VAR^^?}
Decho ${VAR^^}
Attempts:
2 left
💡 Hint
Use Bash parameter expansion for case conversion.
💻 Command Output
advanced
2:00remaining
What is the output of this Bash script snippet?
What will this script output?
Bash Scripting
input="HeLLo WoRLd"
echo "$input" | awk '{print tolower($0)}'
Ahello world
BHeLLo WoRLd (unchanged)
CHELLO WORLD
DHeLLo WoRLd
Attempts:
2 left
💡 Hint
awk's tolower function converts text to lowercase.
🚀 Application
expert
2:30remaining
How many lines will be printed by this script?
This script reads lines from a file and prints only those lines that are uppercase. How many lines will it print?
Bash Scripting
while IFS= read -r line; do
  if [[ "$line" == "${line^^}" ]]; then
    echo "$line"
  fi
done < input.txt
ANo lines will be printed
BAll lines regardless of case
COnly lines that are fully uppercase
DOnly lines that are fully lowercase
Attempts:
2 left
💡 Hint
The condition compares the line to its uppercase version.