double quotes
Quotes that keep text together as one word but still let dollar expansions and backticks work inside.
In more detail
Inside double quotes a variable expands to its value without word splitting or globbing, which is exactly what you want almost every time. A backslash still escapes a dollar sign, a backtick, a double quote or another backslash.
Examples
echo "hello $user"rm "$f"Related terms
- single quotes — Quotes that make every character between them literal, so nothing inside is expanded.
- word splitting — The step where bash cuts the result of an unquoted expansion into separate words at spaces, tabs and newlines.
- globbing — The step where bash replaces a word containing a star, a question mark or square brackets with the sorted list of file names that match it.
- SC2086 — The ShellCheck warning for an unquoted variable expansion, which may be split into several words or expanded as a glob.
Taught in
- Help, History, Completion And Aliases — Bash Scripting & Command Line Automation
- What Bash Does To A Line Before It Runs It — Bash Scripting & Command Line Automation
- Single Quotes, Double Quotes, Backslash — Bash Scripting & Command Line Automation
- The Unquoted Variable: Splitting And Globbing — Bash Scripting & Command Line Automation
- Arrays, And Why Dollar At Is Not Dollar Star — Bash Scripting & Command Line Automation
- Shell Variables, The Environment And export — Bash Scripting & Command Line Automation
- Conditionals: test, Brackets, Double Brackets, case — Bash Scripting & Command Line Automation
- Arguments: Dollar One, Dollar At, shift — Bash Scripting & Command Line Automation
- ShellCheck — Bash Scripting & Command Line Automation
- Style That Prevents Bugs — Bash Scripting & Command Line Automation
- eval, And What To Use Instead — Bash Scripting & Command Line Automation