常用linux 命令 -字符串相关

参考网络文章,个人工作总结

题记:一般对字符串的操作有以下几种:求长度,截取字符串,拼接字符串,找字符串中某个字符的索引

1 expr 命令

1.1 定义

man 手册

 Print  the  value  of  EXPRESSION to standard output.  A blank line below separates increasing precedence
groups. EXPRESSION may be: ARG1 | ARG2
ARG1 if it is neither null nor , otherwise ARG2 ARG1 & ARG2
ARG1 if neither argument is null or , otherwise ARG1 < ARG2
ARG1 is less than ARG2
。。。等等
跟字符串相关的
match STRING REGEXP
same as STRING : REGEXP substr STRING POS LENGTH
substring of STRING, POS counted from index STRING CHARS
index in STRING where any CHARS is found, or length STRING
length of STRING

1.2示例

[devtac@test_1 ~]$ expr length "how can i just let you walk away"
32

[devtac@test_1 ~]$ expr length "how "
4


[devtac@test_1 ~]$ expr substr "how can i just" 2 6
ow can
[devtac@test_1 ~]$ expr index "how can i how" h
1

 
上一篇:Mybatis-Plus入门


下一篇:html5 manifest 离线缓存知识点