Skip to main content
COMMAND-LINE-BASICS5 MIN READ

Quote Variables Like They Might Bite

Use quotes to preserve intended arguments when paths or variable values contain spaces, empty strings, or wildcard characters.

The move: Quote text that must survive shell expansion as one argument. Bash quoting exists because the shell performs transformations before your tool runs. It expands variables, splits unquoted results into words, expands filename patterns, removes quote characters, and only then executes the command. If a variable contains Client A, unquoted expansion can become Client and A. If it contains an asterisk, unquoted expansion can trigger filename expansion. The receiving program sees the result, not your intention. Double quotes are the everyday tool: "$file", "$dir", "$message". They preserve spaces and most literal characters while still allowing $file to expand. Single…

Read the full lesson

Sign up free — one personalized lesson every day, matched to your role and goals.

Already have an account? Sign in

← Back to library
Contact us