close

This example tells us how to extract sub string from a long string.

 

while read stringLine

do

length=`expr length "$stringLine"`

substr=`expr substr "$stringLine" 1 $(($length-1))`

echo $substr

done < input_file

 

Attention:

1. if we want to express a equation in the `expr` , we need to use $(()) to cover this equation.

arrow
arrow
    全站熱搜

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