概述
expr命令一般用于整数值,但也可用于字符串。一般格式为:
expr argument operator argument
① 用空格隔开每个项;
② 用 (反斜杠) 放在 shell 特殊字符前面;
③ 对包含空格和其他特殊字符的字符串要用引号括起来
1、用于数字
$expr 10 + 10
$expr 20 * 2
2、用于字符串
(1)、计算字串长度
> expr length "this is a test" //output : 14
(2)、抓取字串
> expr substr "this is a test" 3 5 //output : is is
(3)、抓取第一个字符数字串出现的位置
> expr index "sarasara" a //output : 2
原文:
http://desheng666.blog.163.com/blog/static/4908408220121643953425/
http://blog.csdn.net/adcxf/article/details/3001275
最后
以上就是玩命手套为你收集整理的expr简介的全部内容,希望文章能够帮你解决expr简介所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复