Question 10
A Linux infrastructure team needs the safest targeted response to this condition: A backup script overwrites a result file because it uses > instead of >>. Which change meets the requirement without weakening unrelated controls?
Explanation
Correct Answer
A single greater-than opens the file in truncation mode. This action corrects the relevant condition. Verify that prior report lines survive the new write.
Incorrect Answers
That remedy is appropriate when a script uses $* without quotes to pass user arguments to a child command. It targets "$@" preserves individual positional arguments as separate quoted words; here a single greater-than opens the file in truncation mode, so it does not directly repair the observed fault.
This change addresses a shell script starts with #!/bin/sh but uses Bash-only arrays. The present problem is different: a single greater-than opens the file in truncation mode. Applying the alternative would leave the key cause unresolved.
It would correct a separate failure, a script uses regex matching inside single brackets where Bash requires extended test syntax. In this environment, a single greater-than opens the file in truncation mode; the indicated alternative does not meet the acceptance test.





CompTIA Linux+ (XK0-006) Practice Tests