#!/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
网友评论