\ Backslash (escaped)

The character literal that follows \ is retained, and the \ is removed on output.

One exception is \newline (backslash + newline), which is treated as a long string newline and is printed with \newline (backslash + newline) removed and ignored.

$ echo \a
a

$ echo \aaa
aaa

$ echo aaa\
> ssss
aaassss

‘single quotation marks

Escape cannot be used

$ echo 'aaa'
aaa

“” double quotation marks

Basic use: Preserve literals

Special case:

  1. ‘$’ :

    $test =asdfg $echo "$test" asdfg $echo "11${test}22" 11asdfg22 # $(command) $echo "aaaa$(ls) SSSS "aaaa1. TXT 2.txtssss # $((expression)) $echo "aaaa$((3+4)) SSSS "aaaa7ssss
  2. ‘`’ :

    $echo "aaaa 'ls' SSSS "aaaa1. TXT 2.txtssss
  3. ‘\’ :

    # the backslash + normal character $echo "\ a \" a # '$',' ` ', '"', '\', or 'newline' (wrap) # backslash + more than a few special symbols, output the backslash would be deleted; Among them, the ` newline ` will also be deleted $echo $\ ` "\ \" = = \ > = = = = = = "$`" # no matter open or close the function of history expansion, ` backslash +! Returns the same output as' backslash + normal '$echo "\! 1 \ "! - 1
  4. When History Expansion starts, ‘! ‘:

    $echo ($echo); $echo ($echo) -1" // Prints last history command echo "echo "\a"" echo a

$’string’

A character in a string that begins with a backslash, if it conforms to ANSI C’s standard escape character, will be escaped to extend the string.

$ echo $'a\naa'
a
aa

$”string”

Strings are translated based on the current locale. A little.

reference

  • Bash Reference Manual:https://www.gnu.org/software/…