Exam XK0-005 Topic 1 Question 665 Discussion
Actual exam question for CompTIA's XK0-005 exam
Question #: 665
Topic #: 1
Question #: 665
Topic #: 1
A user is asking the systems administrator for assistance with writing a script to verify whether a file exists. Given the following:

Which of the following commands should replace the <CONDITIONAL> string?

Which of the following commands should replace the <CONDITIONAL> string?
Suggested Answer: A Vote an answer
The command if [ -f "$filename" ]; then checks if the variable $filename refers to a regular file that exists. The -f option is used to test for files. If the condition is true, the commands after then are executed. This is the correct way to replace the <CONDITIONAL> string. The other options are incorrect because they either use the wrong option (-d tests for directories), the wrong syntax (missing a semicolon after the condition), or the wrong keyword (while is used for loops, not conditions).
by Modesty at Aug 02, 2025, 07:48 PM
0
0
0
10
Comments
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.
Report Comment
Commenting
You can sign-up / login (it's free).