#JSRUN引擎2.0,支持多达30种语言在线运行,全仿真在线交互输入输出。
your_name="runoob"
str="Hello, I know you are \"$your_name\"!\n"
echo $str
echo -e $str
#拼接字符串
#使用双引号拼接
greeting="hello,"$your_name"!"
greeting_1="hello,${your_name}!"
echo $greeting $greeting_1
#使用单引号拼接
greeting_2='hello,'$your_name'!'
#单引号里直接写变量会被当做字符串输出
#hello,runoob! hello,${your_name}!
greeting_3='hello,${your_name}!'
echo $greeting_2 $greeting_3
#获取字符串长度
echo -e "\n"
string="abcd"
echo ${#string}
echo ${#string[0]}
#提取子字符串
string="runoob is a great site"
echo ${string:1:4}
#查找字符串
echo `expr index "$string" i`
string="abcd"
echo `expr index "$string" a`