参考:http://bbs.chinaunix.net/thread-1748468-1-1.html
man bash,可以看到这句话:
Words of the form $'string' are treated specially. The word expands to string, with backslash-escaped characters replaced as speci-
fied by the ANSI C standard. Backslash escape sequences, if present, are decoded as follows:
/a alert (bell)
/b backspace
/e an escape character
/f form feed
/n new line
/r carriage return
/t horizontal tab
/v vertical tab
// backslash
/' single quote
/nnn the eight-bit character whose value is the octal value nnn (one to three digits)
/xHH the eight-bit character whose value is the hexadecimal value HH (one or two hex digits)
/cx a control-x character
意思就是说: $'String' 这种类型会特殊处理,''内的meta元数据是没被关闭的,会被replaced。
这似乎解决了是"echo输出/t( 四个空格)"的另一个答案,只在显示时有用?
eg:
[Gary@localhost ~]$ echo '/t'
/t
[Gary@localhost ~]$ echo $'/t'
[Gary@localhost ~]$ echo $'/t'abvc
abvc
[Gary@localhost ~]$ echo -e "/ta"
a
[Gary@localhost ~]$ echo /t
t
[Gary@localhost ~]$