美文网首页
Shell script: 单引号和双引号的区别

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

作者: louyang | 来源:发表于2018-03-12 13:57 被阅读13次
    #!/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

    相关文章

      网友评论

          本文标题:Shell script: 单引号和双引号的区别

          本文链接:https://www.haomeiwen.com/subject/viynfftx.html