Recall & Review
beginner
What is the main purpose of a report generation script in bash?
To automatically collect data, process it, and create a formatted report file without manual steps.
Click to reveal answer
beginner
Which bash command is commonly used to write output to a file in a report script?
The 'echo' command combined with redirection operators like '>' or '>>' is used to write or append output to a file.
Click to reveal answer
beginner
How can you include the current date and time in a bash report?
Use the 'date' command, for example: $(date) to insert the current date and time into the report.
Click to reveal answer
intermediate
Why is it useful to check if a file exists before writing a report in bash?
To avoid overwriting important data accidentally or to decide whether to append or create a new report file.
Click to reveal answer
beginner
What does the '>>' operator do in a bash script?
It appends output to the end of a file without deleting the existing content.
Click to reveal answer
Which command adds the current date to a report file in bash?
✗ Incorrect
Option C uses echo with command substitution to append the current date to the report file.
What does the '>' operator do in a bash script?
✗ Incorrect
The '>' operator overwrites the file with new output, replacing any existing content.
How do you check if a file named 'report.txt' exists in bash?
✗ Incorrect
The '[ -f filename ]' test checks if a regular file exists.
Which command appends text 'Hello' to a file named 'output.txt'?
✗ Incorrect
Using '>>' appends the text to the file without deleting existing content.
What is a good reason to automate report generation with a bash script?
✗ Incorrect
Automation saves time and reduces mistakes by handling repetitive tasks automatically.
Explain the basic steps to create a simple report generation script in bash.
Think about how you gather info, format it, and save it in a file.
You got /5 concepts.
Describe how you would safely update a report file daily using a bash script.
Consider file existence and preserving old data.
You got /5 concepts.