Skip to main content
Linux AdministrationMediumSingle Choice

Linux Administration Question

Statement

What is the difference between the commands test -e path and test -f path?

#test#file-testing#regular-file#path-existence
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.

Correct
D

The -f option tests for a regular file. The -e option tests for an executable file.

Resolution & Explanations

test -e returns true if the file exists (any type). test -f returns true only if the file exists and is a regular file.