0
0
Bash Scriptingscripting~20 mins

Color output (ANSI escape codes) in Bash Scripting - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
ANSI Color Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
What is the output color of this script?
This bash script prints the word Success in a specific color. What color will the text appear as in the terminal?
Bash Scripting
echo -e "\e[32mSuccess\e[0m"
AGreen
BRed
CBlue
DYellow
Attempts:
2 left
💡 Hint
Look up the ANSI color code 32.
💻 Command Output
intermediate
1:30remaining
What will this script output?
This script prints two words with different colors. What will be the color of the word Error?
Bash Scripting
echo -e "\e[33mWarning\e[0m and \e[31mError\e[0m"
AWarning is red, Error is yellow
BWarning is yellow, Error is red
CBoth words are red
DBoth words are yellow
Attempts:
2 left
💡 Hint
Check the ANSI codes 33 and 31.
📝 Syntax
advanced
2:00remaining
Which option correctly prints Done in bold blue?
Choose the correct bash command that prints the word Done in bold blue text.
Aecho -e "\e[1m\e[34mDone\e[0m"
Becho -e "\e[34;1mDone\e[0m"
Cecho -e "\e[1;34mDone\e[0m"
Decho -e "\e[34m\e[1mDone\e[0m"
Attempts:
2 left
💡 Hint
The order of codes in the escape sequence matters.
🔧 Debug
advanced
2:00remaining
Why does this script not color the output?
This script is intended to print Alert in red, but the output is plain text. What is the problem?
Bash Scripting
echo "\e[31mAlert\e[0m"
AThe backslashes should be doubled like \\e
BThe color code 31 is incorrect for red
CThe reset code \e[0m is missing
DThe echo command needs the -e option to interpret escape codes
Attempts:
2 left
💡 Hint
Try running the command with -e option.
🚀 Application
expert
2:30remaining
How to print a blinking yellow warning message?
You want to print the word Warning in blinking yellow text using ANSI escape codes in bash. Which command achieves this?
Aecho -e "\e[5;33mWarning\e[0m"
Becho -e "\e[33m\e[5mWarning\e[0m"
Cecho -e "\e[33;5mWarning\e[0m"
Decho -e "\e[1;33mWarning\e[0m"
Attempts:
2 left
💡 Hint
Blinking code is 5, yellow is 33; order matters.