Challenge - 5 Problems
Shell Scripting Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate1:30remaining
What is the output of this Bash command?
Consider the following command run in Bash shell:
What will be printed on the screen?
echo $((3 + 5 * 2))What will be printed on the screen?
Linux CLI
echo $((3 + 5 * 2))
Attempts:
2 left
💡 Hint
Remember the order of operations in arithmetic expressions.
✗ Incorrect
In arithmetic, multiplication happens before addition. So 5 * 2 = 10, then 3 + 10 = 13.
📝 Syntax
intermediate1:30remaining
Which option correctly defines a function in Bash?
You want to create a function named
greet that prints 'Hello'. Which of these is the correct syntax?Attempts:
2 left
💡 Hint
Bash functions can be declared with or without the 'function' keyword, but syntax matters.
✗ Incorrect
Option A uses the correct Bash syntax: 'function name { commands; }'. Other options have syntax errors or use other languages' syntax.
🔧 Debug
advanced2:00remaining
Why does this script fail to print the variable value?
Given this script:
What is the reason for the output being empty?
#!/bin/bash
VAR=5
if [ $VAR -gt 3 ]
then
echo "Value is $var"
fiWhat is the reason for the output being empty?
Linux CLI
#!/bin/bash VAR=5 if [ $VAR -gt 3 ] then echo "Value is $var" fi
Attempts:
2 left
💡 Hint
Check how variable names are written and used.
✗ Incorrect
Bash variables are case-sensitive. VAR and var are different. The script sets VAR but prints $var, which is empty.
🚀 Application
advanced2:00remaining
Which command lists all files including hidden ones in long format sorted by modification time?
You want to see all files, including hidden ones (those starting with a dot), in your current directory. You want the list in long format and sorted by newest modified first. Which command achieves this?
Attempts:
2 left
💡 Hint
Check what each option means: -l, -a, -t, -r
✗ Incorrect
-l shows long format, -a shows hidden files, -t sorts by modification time newest first, -r reverses order. So -lat lists all files long format sorted newest first.
🧠 Conceptual
expert2:00remaining
What happens when you run this pipeline in Bash?
Consider this command:
What will be the output?
echo 'apple banana cherry' | while read word; do echo $word; doneWhat will be the output?
Attempts:
2 left
💡 Hint
Think about how 'read' works with default IFS and how the pipeline feeds input.
✗ Incorrect
The 'read word' command splits the input line on whitespace (default IFS=space/tab/newline), assigning only the first field 'apple' to 'word'. The rest ('banana cherry') is discarded. Since there's only one line, the loop runs once.