149k views
4 votes
How would you write a test that says "if /tmp/foo is a directory or USERS is greater than 5"?

A) test -d /tmp/foo -o $USERS -gt 5
B) test -d /tmp/foo | $USERS > 5
C) test /tmp/foo || $USERS > 5
D) test /tmp/foo -d -o $USERS -gt 5

User Daut
by
8.4k points

1 Answer

0 votes

The correct command to test if /tmp/foo is a directory or if USERS is greater than 5 is 'test -d /tmp/foo -o $USERS -gt 5'. It uses flags to check directory existence and numerical comparison.

To write a test that checks if /tmp/foo is a directory or if the USERS variable is greater than 5, you can use the following command:

A) test -d /tmp/foo -o $USERS -gt 5

This command uses the test command to check if the /tmp/foo is a directory with -d. It then uses -o to represent the logical OR operator, and checks if the value of USERS is greater than 5 with -gt (greater than). The correct answer does not include irrelevant commands or incorrect syntax such as pipe or lack of operators.

User Y N
by
7.8k points