1) 由单引号‘ ‘
包围的字符串:
2) 由双引号" "
包围的字符串:
3) 不被引号包围的字符串
" "
包围的字符串一样。#!/bin/bash # shell只有数字和字符串两种类型 #单引号有问题 n=56 a1=num=$n a2=‘num=$n‘ a3="num=$n" echo $a1 echo $a2 echo $a3 #无引号有问题 #b1=china is nice b2=‘china is nice‘ b3="china is nice" echo $b1 echo $b2 echo $b3 #获取字符串长度 c1="super star is reba" echo ${#c1}
来自shell的随笔均参考自 http://c.biancheng.net/view/1114.html
原文:https://www.cnblogs.com/oytt/p/13398266.html