exam questions

Exam XK0-004 All Questions

View all questions & answers for the XK0-004 exam

Exam XK0-004 topic 1 question 122 discussion

Actual exam question from CompTIA's XK0-004
Question #: 122
Topic #: 1
[All XK0-004 Questions]

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?

  • A. $(cat ip-list.txt) should be changed to `cat ip-list.txt` in the for statement.
  • B. The for should be changed to while in the loop.
  • C. The > should be changed to 2> in the do statement.
  • D. The -ne flag should be changed to -eq in the if statement.
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
ssc1982
Highly Voted 4 years, 4 months ago
D is the answer, if the script finds company A, the result should be equal to 0
upvoted 13 times
FilipIT
4 years, 3 months ago
exactly
upvoted 2 times
...
o0o0
3 years, 11 months ago
I confirm
upvoted 1 times
...
...
luken7777
Most Recent 1 year, 9 months ago
I didn't know that 0 return means success - in programming languages 0 is false and 1 is true. Lol.
upvoted 1 times
...
DiaaEmara
2 years, 4 months ago
The answer can’t be a because the single quotes mean in the command inside won’t be interpreted. b can’t be because it doesn’t make sense , and c also doesn’t make sense. However if you change the -ne to -eq it will make grep act quietly in the back ground which is probably the issue. So the answer is D. Plus no other command except grep has a q flag, and since $? Refers to the last run command it makes sense and the -n option numbers lines in a file which shouldn’t be there. https://linuxcommand.org/lc3_man_pages/grep1.html
upvoted 1 times
...
examtopics_htc
2 years, 6 months ago
Selected Answer: D
Exit 0 means the last command passed without errors, so you want to check for an exit status of 0 before continuing with the echo
upvoted 1 times
...
miky_Cissp
4 years, 1 month ago
D is the correct answer. I tested it.
upvoted 3 times
...
francocaorlini
4 years, 3 months ago
Sorry, D is the correct one
upvoted 3 times
...
francocaorlini
4 years, 3 months ago
A is the answer..
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago