Premium lesson

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 World

Where:

  • echo is the command.

  • Hello and World are 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 World
icon light bulb key

Unlock 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
Unlock this module