expr 常用在數值運算上面,但他也可以用在字串的簡單處理,以下來簡介他的用法
數值運算
加
ex:
expr 10 + 3
減
ex:
expr 10 - 3
乘
ex:
expr 10 * 3
除
ex: 10 / 3
字串處理
取字串長度
ex:expr length "this is a test string"
result: 21
從第n個字起取m個字
ex:expr substr "this is a test string" 3 4
result :is i
此範例在字串 this is a test string 裡面從第3個字起取4個字 結果為 :is i (空白也算喔 )
星期一, 1月 21, 2008
Linux :expr 使用方法
張貼者: 拉不拉多的夢幻世界 於 12:39 上午
標籤:
linux,
Shell Script
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言