Server Administration

A Bash maintenance script must use a directory path containing spaces as one argument to a backup utility. How should the script reference the variable holding that path?

Show the answer

Correct answerD. Enclose the variable reference in double quotes

AWhy not this: Backticks perform command substitution rather than protecting a variable's value as one argument.

BWhy not this: Single quotes prevent variable expansion, so the utility receives the literal reference rather than the stored path.

CWhy not this: An unquoted expansion can split the path into multiple arguments at spaces.

DWhy this is right: Double quotes expand the variable while keeping spaces within a single argument.

Double quotes allow variable expansion while preventing word splitting, preserving the path as one argument. Single quotes preserve the variable reference literally instead of substituting its value.