Linux Foundation Certified System Administrator (LFCS) — Question 26
What is the difference between the commands test -e path and test -f path?
Answer options
- A. They are equivalent options with the same behavior.
- B. The -f option tests for a regular file. The -e option tests for an empty file.
- C. Both options check the existence of the path. The -f option also confirms that it is a regular file.
- D. The -f option tests for a regular file. The -e option tests for an executable file.
Correct answer: C
Explanation
The correct answer is C because both -e and -f options check if the specified path exists, but -f specifically verifies that the path is a regular file. Options A, B, and D are incorrect as they misinterpret the functionality of the -e and -f options, particularly regarding what constitutes a regular file and the nature of the checks performed.