Which of the following explains what is wrong with the script?

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.

comptia-exams

2 thoughts on “Which of the following explains what is wrong with the script?

  1. 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

    1. I’m not following the logic here. Where are you seeing a q option passed to grep in the above code? Where is this -n option you are referring to? I’m not implying you are wrong; I just don’t understand what you are saying here.

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.