Challenge - 5 Problems
Report Script Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Output of a simple report generation script
What is the output of this bash script that generates a report of file counts in the current directory?
Bash Scripting
#!/bin/bash count=$(ls -1 | wc -l) echo "Total files: $count"
Attempts:
2 left
💡 Hint
The script counts files in the current directory and prints the total.
✗ Incorrect
The command ls -1 lists files one per line, wc -l counts lines, so the variable count holds the number of files. The echo prints the total files count.
📝 Syntax
intermediate2:00remaining
Identify the syntax error in this report script
Which option contains the syntax error in this bash script that summarizes disk usage?
Bash Scripting
du -sh * > report.txt
echo "Report saved to report.txt"Attempts:
2 left
💡 Hint
Look for unmatched quotes or extra characters.
✗ Incorrect
Option B has an extra double quote at the end of the echo line, causing a syntax error.
🔧 Debug
advanced2:00remaining
Why does this report script fail to write output?
This script is supposed to write a list of running processes to a file named 'process_report.txt'. Why does it fail?
Bash Scripting
#!/bin/bash
ps aux > process_report.txt
cat process_report.txtAttempts:
2 left
💡 Hint
Check if the commands are valid and redirection is correct.
✗ Incorrect
The script runs correctly: ps aux lists processes, output redirected to file, then cat prints the file content.
🚀 Application
advanced2:00remaining
Which script correctly appends a timestamp to a report file?
You want to add the current date and time at the end of 'report.txt'. Which script does this correctly?
Attempts:
2 left
💡 Hint
Use command substitution to get the current date output.
✗ Incorrect
Option A uses $(date) to insert the current date and time as a string, appending it to the file.
🧠 Conceptual
expert2:00remaining
What is the number of lines in the report generated by this script?
This script lists all '.log' files and counts lines in each, saving output to 'log_report.txt'. How many lines will 'log_report.txt' contain if there are 3 '.log' files?
Bash Scripting
#!/bin/bash
wc -l *.log > log_report.txtAttempts:
2 left
💡 Hint
The wc command outputs one line per file plus a total line.
✗ Incorrect
wc -l with multiple files outputs one line per file plus a summary line, so 3 files produce 4 lines.