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.
echo 'String in single quote'
echo "String in double quote"
mkdir 'Dir 1'
mkdir "Dir 2"
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.