str='this is a string'单引号字符串的限制:
your_name='qinjx' str="Hello, I know your are \"$your_name\"! \n"双引号的优点:
your_name="qinjx" greeting="hello, "$your_name" !" greeting_1="hello, ${your_name} !" echo $greeting $greeting_1获取字符串长度
string="abcd" echo ${#string} #输出 4提取子字符串
string="alibaba is a great company" echo ${string:1:4} #输出liba查找子字符串
string="alibaba is a great company" echo `expr index "$string" is`
原文地址:http://blog.csdn.net/wu20093346/article/details/47188209