Quoting & Escaping Parameters
Shell·2 min read·Jan 1, 2025
In Bash, quoting refers to the process of enclosing command parameters within single quotes ' and double quotes " to influence the way commands are interpreted and executed by the shell.
On the other hand, escaping refers to the process of selectively preventing shell expansions using the backslash character \.
Defining multi-words command parameters
By default, the shell uses whitespace characters, such as spaces, tabs, and newlines as delimiters to break down commands into distinct elements.
For example, the shell will break down this expression into 1 command and 2 parameters:
$ echo Hello WorldWhere:
-
echois the command. -
HelloandWorldare the parameters.
To force the shell to treat the string "Hello World" as a single parameter instead of two, you can wrap this expression into single quotes:
$ echo 'Hello World'Hello WorldUnlock the CLI & Scripting with Bash module
Learn how to gain advanced control over the OS and automate complex routine tasks prone to manual errors with the CLI and Bash scripting.
You get immediate access to:
- 34 focused lessons across the CLI and Bash
- 4 real-world projects with commented solutions
- Ongoing updates to this bundle
- Lifetime access to this bundle