Question 490
The lab examiner asks for evidence after this assignment: A script generates a timestamped training archive but literal quotes around the `date` substitution prevent expansion. What is the decisive verification step?
Explanation
Correct Answer
The resulting filename contains the current date digits and `tar -tzf` lists expected members. This check confirms the expected effect of: Use `stamp=$(date +%Y%m%d)` and `tar -czf "/tmp/archive-$stamp.tgz" -C /srv/labs projectA`. It distinguishes the intended result from the original failure mechanism: Single quotes suppress shell substitutions; double-quoted variable expansion preserves values.
Incorrect Answers
Known values 9 and 10 route to different expected branches. That verifies a separate lab task: A script's `if` statement tests a numeric threshold using string comparison and misorders the values 9 and 10. It does not validate the implementation required here: Use `stamp=$(date +%Y%m%d)` and `tar -czf "/tmp/archive-$stamp.tgz" -C /srv/labs projectA`.
The file `/tmp/lab reports/status.txt` receives the line and no extra files are created. That verifies a separate lab task: A training script appends to a log whose path includes spaces and breaks because the variable is expanded unquoted. It does not validate the implementation required here: Use `stamp=$(date +%Y%m%d)` and `tar -czf "/tmp/archive-$stamp.tgz" -C /srv/labs projectA`.
In a fixture where the first command exits 1, the second command does not run. That verifies a separate lab task: A script invokes two commands on one line with a semicolon and prints success even if the first fails. It does not validate the implementation required here: Use `stamp=$(date +%Y%m%d)` and `tar -czf "/tmp/archive-$stamp.tgz" -C /srv/labs projectA`.