Bash parses single- and double-quotes slightly differently. Single-quotes are simpler, so I'll cover them first.
A single-quoted string (or single-quoted section of a string -- I'll get to that) runs from a single-quote to the next single-quote. Anything other than a single-quote (including double-quotes, backslashes, newlines, etc) is just a literal character in the string. But the next single-quote ends the single-quoted section. There is no way to put a single-quote inside a single-quoted string, because the next single-quote will end the single-quoted section.
You can have differently-quoted sections within a single "word" (or string, or whatever you want to call it). So, for example, ''hello''
will be parsed as a zero-length single-quoted section, the unquoted section hello
, then another zero-length single-quoted section. Since there's no whitespace between them, they're all treated as part of the same word (and since the single-quoted sections are zero-length, they have no effect at all on the resulting word/string).
Double-quotes are slightly different, in that some characters within them retain their special meanings. For example, $
can introduce variable or command substitution, etc (although the result won't be subject to word-splitting like it would be without the double-quotes). Backslashes also function as escapes inside double-quotes, so \$
will be treated as a literal dollar-sign, not as the start of a variable expansion or anything. Other characters that can have their special meaning removed by backslash-escaping are backslashes themselves, and... double-quotes! You can include a double-quote in a double-quote by escaping it. The double-quoted section ends a the next non-escaped double-quote.
So compare:
echo ""hello"" # just prints hello
echo "\"hello\"" # prints "hello", because the escaped
# quotes are part of the string
echo "$PATH" # prints the value of the PATH variable
echo "\$PATH" # prints $PATH
echo ""'$PATH'"" # prints $PATH, because it's in
# single-quotes (with zero-lenght
# double-quoted sections on each side
Also, single- and double-quotes have no special meaning within the other type of quote. So:
echo "'hello'" # prints 'hello', because the single-quotes
# are just ordinary characters in a
# double-quoted string
echo '"hello"' # similarly, prints "hello"
echo "'$PATH'" # prints the PATH variable with
# single-quotes around it (because
# $variable expands in double-quotes)