指令名称:expr
功能介绍:可以对字符串进行各种处置
语法格式:expr
常用参数说明:
指令使用实例:
1.字串长度
shell>> expr length "this is a test"
14
2.数字商数
shell>> expr 14 % 9
5
3.从位置处抓取字串
shell>> expr substr "this is a test" 3 5
is is
4.数字串 only the first character
shell>> expr index "testforthegame" e
2
5.字串真实重现
shell>> expr quote thisisatestformela
thisisatestformela
本文来自ChinaUnix博客,如果查看原文请点:[url]http://blog.chinaunix.net/u2/82877/showart_1675426.html[/url]
功能介绍:可以对字符串进行各种处置
语法格式:expr
常用参数说明:
指令使用实例:
1.字串长度
shell>> expr length "this is a test"
14
2.数字商数
shell>> expr 14 % 9
5
3.从位置处抓取字串
shell>> expr substr "this is a test" 3 5
is is
4.数字串 only the first character
shell>> expr index "testforthegame" e
2
5.字串真实重现
shell>> expr quote thisisatestformela
thisisatestformela
本文来自ChinaUnix博客,如果查看原文请点:[url]http://blog.chinaunix.net/u2/82877/showart_1675426.html[/url]
本文详细介绍了 Shell 中的 expr 命令及其用法,包括计算字符串长度、求余数、截取子字符串、查找字符位置以及引用字符串等实用操作。通过具体的示例演示了如何使用这些功能。
2463

被折叠的 条评论
为什么被折叠?



