10.5k views
4 votes
True if a file exists and its size is greater than zero.

A) test -e file
B) test -z file
C) test -n file
D) test -s file

User Majed DH
by
8.5k points

1 Answer

1 vote

Final answer:

The correct answer is D) test -s file. This command checks if a file exists and its size is greater than zero bytes. Other options, like test -e, test -z, and test -n, have different uses.

Step-by-step explanation:

The student is asking about a command that can be used to check if a file exists and if it is greater than zero bytes in size. In the options provided, test -s file is the correct answer.

The test command is used in shell scripts to check file types and compare values. The test -s option returns true if the file exists and its size is greater than zero bytes. On the other hand, test -e checks only if the file exists, test -z checks if the file size is zero bytes, and test -n is not used to check files; rather, it checks if a string is non-zero.

User Alfred Xiao
by
7.9k points