Automation, Orchestration, and Scripting

A backup script must stop with an error if the directory /var/backups is missing. Which test belongs in the if statement that triggers the error branch?

Show the answer

Correct answerD. [ ! -d /var/backups ]

The ! operator negates the -d test, so the expression succeeds only when /var/backups is not an existing directory. Using ! with -f only checks that the path is not a regular file, which is also true for a directory, so the error would fire wrongly.