= Bash Quoting = <> ---- == Escaping Characters == Certain characters cause the shell to interpret commands and arguments differently. The primary example is the space character, which the shell [[Bash/Expansion#Word_Splitting|interprets as a delimiter between tokens]]. These characters can be '''escaped''' to prevent their misinterpretation. The escape character is the backwards slash (`\`). {{{ a=foo\ bar }}} The primary challenge with escaping characters is that every time the shell interprets an escaped character, the escape is removed. Commands that will be passed between shells can require multiple escapes. ---- == Quoting == If a string is quoted within single quotes (`'`), it is treated as a literal string. No [[Bash/Expansion|expansion]] will apply to the value. The single quote character can not be used within a string quoted by single quotes, even when escaped. If a string is quoted within double quotes (`"`), it is treated as a single token. [[Bash/Expansion#History_Expansion|History expansion]] (if enabled) and [[Bash/Expansion#Command_Expansion|command expansion]] do apply to the value. The double quote character can be used within a string quoted by souble quotes ''if'' it is escaped. Similarly, to use the literal characters that trigger history (`!`) and command (`$`, {{{`}}}) expansions, escape them. The escape character itself (`\`) also needs to be escaped to be used literally. ---- == ANSI Quoting == If a string is quoted within `$'...'`, then it expands to a string with backslash-escaped characters translated per [[C/ANSISequences|C ANSI escape sequences]]. The non-ANSI sequences `\E` (same as `\e`) and `\cx` (control characters) are also expanded. ---- == Localization == If a string is quoted within `$"..."`, then it expands to a string translated through the current locale. ---- CategoryRicottone