1. Home
  2. Bash
  3. Bash Tutorial
  4. Bash – Quotes

Bash – Quotes

Quotes in Bash

This is a standard practice to quote the string in any programming language. Quotes are used to deal with the texts, filenames with a space character. Read this tutorial to understand the differences between single quote and double quotes.

Quote with String

While working with simple texts and string, there are no different in using a single quote or double quote.

The above script will run without any error and print the messages and create both directories.

Quote with Variables

Just remember that the shell variable expansion will work with double quotes only. If you define any variable in single quote will not work.

#!/bin/bash

NAME="Welcome TecAdmin"

echo "$NAME"
echo '$NAME'

Now execute this script. The first echo will print the value of variable ie “Welcome TecAdmin”, But the second variable will print only $NAME due to enclosed in single quote.

Tags , ,
Was this article helpful to you? Yes 6 No
Advertisement