XK0-006 · Question #70
A systems administrator needs to write a script that counts the number of times "FAIL" appears in a log file. If "FAIL" appears zero times, then the administrator would like to print the message…
The correct answer is D. -eq. The test should check if the count of "FAIL" equals zero. The operator -eq is used for numeric equality in shell conditionals, so [ $(grep -c FAIL /var/file.log) -eq 0 ] correctly evaluates whether the count is zero.
Question
A systems administrator needs to write a script that counts the number of times “FAIL” appears in a log file. If “FAIL” appears zero times, then the administrator would like to print the message “SUCCESS.” Given the following:
Which of the following should be used before the zero to complete the script?
Exhibit
Options
- A-ne
- B-gt
- C-lt
- D-eq
How the community answered
(49 responses)- A6% (3)
- B2% (1)
- C4% (2)
- D88% (43)
Explanation
The test should check if the count of "FAIL" equals zero. The operator -eq is used for numeric equality in shell conditionals, so [ $(grep -c FAIL /var/file.log) -eq 0 ] correctly evaluates whether the count is zero.
Topics
Community Discussion
No community discussion yet for this question.
