文章目录
#和%用法
[root@localhost ~]#url=www.123.456.789.com.cn
[root@localhost ~]#echo $url
www.123.456.789.com.cn
[root@localhost ~]#echo ${#url}
22
[root@localhost ~]#echo ${url#.}
www.123.456.789.com.cn
[root@localhost ~]#echo ${url#.*}
www.123.456.789.com.cn
[root@localhost ~]#echo ${url#*.}
123.456.789.com.cn
[root@localhost ~]#echo ${url##*.}
cn
[root@localhost ~]#echo ${url%*.}
www.123.456.789.com.cn
[root@localhost ~]#echo ${url%.*}
www.123.456.789.com
[root@localhost ~]#echo ${url%%.*}
www
知道其中一部分内容
[root@localhost ~]#echo ${url%.123*}
www
[root@localhost ~]#echo ${url%.456*}
www.123
[root@localhost ~]#echo ${url%*456*}
www.123.
[root@localhost ~]#echo ${url%*45*}
www.123.
[root@localhost ~]#echo ${url%*56*}
www.123.4
[root@localhost ~]#echo ${url#*123.}
456.789.com.cn
[root@localhost ~]#echo ${url#*456.}
789.com.cn
[root@localhost ~]#echo ${url#*456*}
.789.com.cn
[root@localhost ~]#echo ${url#*56*}
.789.com.cn
[root@localhost ~]#echo ${url#*45*}
6.789.com.cn
更详细的内容