Skip to main content

Difference between single (' ') quote vs double (" ") quote

Single Quote

Using single quote in bash script will preserve the literal value of each characters in the single quotes. It will not do any variable interpolation but instead treat it as it is.

Double Quote

Using double quote it will preserve the literal value as well except $, `, \ which will expand those variables or commands.

Aside: Passing \n as Bash Argument

To pass the actual newline character not the literal in Bash you can do it in the following ways.

./myProgram "
"

OR

./myProgram $'\n'

Do not try to pass it via ./myProgram "\n' this will escape the backslash so your actual string that gets passed is "\\n".