为什么 echo 和 "SENTENCE" 之间需要美元符号
Why does dollar sign is needed between echo and "SENTENCE"
我在 /etc/init.d/* 脚本中发现 echo $"<SENTENCE>"
与 echo $"Starting $prog: "
相似。
我在 CentOS6.7 服务器上使用终端进行了测试。但是我不明白为什么 "<SENTENCE>"
.
之前需要“$”
$ prog=sample_process
$ echo $"Starting $prog: "
Starting test_process:
$ echo "Starting $prog: "
Starting test_process:
[问题]
为什么在 echo
和 "SENTENCE" 之间需要 '$'?在我看来,echo $"Starting $prog: "
和echo "Starting $prog: "
都是一样的。
man bash
,引用下:
A double-quoted string preceded by a dollar sign ($"string"
) will cause
the string to be translated according to the current locale. If the
current locale is C or POSIX, the dollar sign is ignored. If the
string is translated and replaced, the replacement is double-quoted.
编辑:tutorial.
我在 /etc/init.d/* 脚本中发现 echo $"<SENTENCE>"
与 echo $"Starting $prog: "
相似。
我在 CentOS6.7 服务器上使用终端进行了测试。但是我不明白为什么 "<SENTENCE>"
.
$ prog=sample_process
$ echo $"Starting $prog: "
Starting test_process:
$ echo "Starting $prog: "
Starting test_process:
[问题]
为什么在 echo
和 "SENTENCE" 之间需要 '$'?在我看来,echo $"Starting $prog: "
和echo "Starting $prog: "
都是一样的。
man bash
,引用下:
A double-quoted string preceded by a dollar sign (
$"string"
) will cause the string to be translated according to the current locale. If the current locale is C or POSIX, the dollar sign is ignored. If the string is translated and replaced, the replacement is double-quoted.
编辑:tutorial.