- 如果沒有特殊定製bash環境或有特殊需求,$"string"和"string"是完全等價的
- $後接單引號的$‘string’,這在bash中被特殊對待:會將某些反斜線序列(如\n,\t,",'等)繼續轉義,而不認爲它是字面符號(如果沒有$符號,單引號會強制將string翻譯爲字面符號,包括反斜線)。
例:
[root@python ~]# echo $"a\nb"
a\nb
[root@python ~]# echo $'a\nb'
a
b
[root@python ~]# echo 'a\nb'
a\nb
[root@python ~]# echo "a\nb"
a\nb
[root@python ~]#