4.Shell 字符串
Shell 字符串
单引号
1.str='this is a string'
双引号
1.your_name='qinjx'
2.str="Hello, I know your are \"$your_name\"! \n"
拼接字符串
获取字符串长度
提取子字符串
查找子字符串
Last updated
Shell 字符串
单引号
1.str='this is a string'
双引号
1.your_name='qinjx'
2.str="Hello, I know your are \"$your_name\"! \n"
拼接字符串
获取字符串长度
提取子字符串
查找子字符串
Last updated
1.your_name="qinjx"
2.greeting="hello, "$your_name" !"
3.greeting_1="hello, ${your_name} !"
4.echo $greeting $greeting_11.string="abcd"
2.echo ${#string} #输出 41.#!/bin/bash
2.
3.your_name="onetwothree"
4.
5.echo $(#your_name)1.[root@localhost lcr]# ./helloworld.sh
2../helloworld.sh:行5: 寻找匹配的 `)' 是遇到了未预期的文件结束符
3../helloworld.sh:行8: 语法错误: 未预期的文件结尾1.string="runoob is a great site"
2.echo ${string:1:4} # 输出 unoo1.#!/bin/bash
2.
3.your_name="runoob is a great site"
4.echo ${your_name:5:11}1.b is a grea
2.[root@localhost lcr]# ./helloworld.sh
3.b is a grea1.string="runoob is a great company"
2.echo `expr index "$string" is` # 输出 81.#!/bin/bash
2.
3.string="LCR is not loser"
4.
5.echo `expr index "$string" is`