Shell script: 单引号和双引号的区别

2018-03-12  本文已影响13人  louyang
#!/bin/sh
MYVAR=sometext
echo "double quotes gives you $MYVAR"
echo 'single quotes gives you $MYVAR'

运行:

double quotes gives you sometext
single quotes gives you $MYVAR

所以,双引号内部的变量会转换成其值,而单引号不会。

参考

https://stackoverflow.com/questions/6697753/difference-between-single-and-double-quotes-in-bash
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html

上一篇下一篇

猜你喜欢

热点阅读