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 (空白也算喔 )
arrow
arrow
    全站熱搜

    yuanann 發表在 痞客邦 留言(0) 人氣()