XK0-005 · Question #1128
An analyst is trying to determine which public IP addresses are managed by Company A, but the script is not working correctly. Which of the following explains what is wrong with the script?
The correct answer is D. The -ne flag should be changed to -eq in the if statement. The error is that the -ne flag (not equal) should be changed to -eq (equal) in the if statement. In the context of this script - which likely runs whois or a similar lookup against a list of IPs and checks whether the output matches 'Company A' - the condition logic is…
Question
Exhibit
Options
- A$(cat ip-list.txt) should be changed to
cat ip-list.txtin the for statement. - BThe for should be changed to while in the loop.
- CThe > should be changed to 2> in the do statement.
- DThe -ne flag should be changed to -eq in the if statement.
How the community answered
(22 responses)- A9% (2)
- B5% (1)
- C5% (1)
- D82% (18)
Explanation
The error is that the -ne flag (not equal) should be changed to -eq (equal) in the if statement. In the context of this script - which likely runs whois or a similar lookup against a list of IPs and checks whether the output matches 'Company A' - the condition logic is inverted. Using -ne would cause the script to process IPs that do NOT match Company A and skip ones that do, producing the opposite of the intended result. Option A is incorrect because both $() and backtick syntax are valid for command substitution. Option B is incorrect because a for loop iterating over file contents is a standard and correct pattern. Option C is incorrect because > redirects stdout to a file, and 2> redirects stderr; changing this would affect error output, not the filtering logic. The logical operator (-ne vs -eq) is the root cause of the incorrect filtering.
Topics
Community Discussion
No community discussion yet for this question.
