What is the difference between the commands test -e path and test -f path?
What is the difference between the commands test -e path and test -f path?
A . They are equivalent options with the same behaviour.
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.
Answer: C
Explanation:
The test command is used to perform checks and comparisons on files and values. The -e option tests if a given path exists, regardless of its type (file, directory, link, etc.). The -f option tests if a given path exists and is a regular file, not a directory or a special file. For example, if we have a directory named dir and a file named file, we can use the test command as follows:
test -e dir && echo “dir exists” dir exists test -f dir && echo “dir is a regular file” (no output) test -e file && echo “file exists” file exists test -f file && echo “file is a regular file” file is a regular file
Reference: https://www.howtoforge.com/linux-test-command/ https://www.computerhope.com/unix/bash/test.htm
Latest 102-500 Dumps Valid Version with 194 Q&As
Latest And Valid Q&A | Instant Download | Once Fail, Full Refund