0
0
Bash Scriptingscripting~20 mins

Why patterns solve common automation needs in Bash Scripting - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Automation Pattern Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Output of a loop pattern in Bash
What is the output of this Bash script?
Bash Scripting
for i in {1..3}; do echo "Step $i"; done
A
1
2
3
B
Step 1
Step 2
Step 3
CStep 1 Step 2 Step 3
DStep 3
Attempts:
2 left
💡 Hint
Look at how the loop prints each step on a new line.
🧠 Conceptual
intermediate
2:00remaining
Why use patterns in automation scripts?
Which reason best explains why using common patterns helps in automation scripting?
APatterns reduce errors by reusing tested solutions.
BPatterns prevent scripts from running on weekends.
CPatterns make scripts run slower but look nicer.
DPatterns increase the number of manual steps needed.
Attempts:
2 left
💡 Hint
Think about how reusing solutions affects reliability.
📝 Syntax
advanced
2:00remaining
Identify the correct Bash pattern for checking file existence
Which option correctly checks if a file named 'data.txt' exists in Bash?
Aif -f data.txt; then echo "File exists"; fi
Bif ( -f data.txt ) then echo "File exists"; fi
Cif [[ -f data.txt ]]; then echo "File exists"; end
Dif [ -f data.txt ]; then echo "File exists"; fi
Attempts:
2 left
💡 Hint
Remember the correct syntax for the test command and if statement.
🔧 Debug
advanced
2:00remaining
Find the error in this automation script snippet
What error does this Bash script produce? code: count=0 while [ $count -lt 3 ] do echo "Count is $count" count=$count+1 done
ASyntaxError: missing 'then' keyword
BOutputs 'Count is 0' infinitely
Ccount variable does not increment, infinite loop
DScript runs correctly and stops after 3 counts
Attempts:
2 left
💡 Hint
Check how the count variable is updated inside the loop.
🚀 Application
expert
2:00remaining
Automate file backup with timestamp pattern
Which Bash command correctly copies 'report.txt' to a backup file with the current date appended (format YYYY-MM-DD)?
Acp report.txt report_$(date +%Y-%m-%d).txt
Bcp report.txt report_$(date %Y-%m-%d).txt
Ccp report.txt report_$(date +%y-%m-%d).txt
Dcp report.txt report_$(date +%Y/%m/%d).txt
Attempts:
2 left
💡 Hint
Check the correct syntax for date formatting in command substitution.