cmd:expr string operation 

Usage 

$ expr substr "asdfsadf" 1 5
$ expr length asfasdf

Help 

substr string i_start i_length
Extract the substring of string starting at position i_start and of length i_length characters. If i_start has a value greater than the length of string, expr returns a null string. If you try to extract more characters than there are in string, expr returns all the remaining characters from string. Beware of using negative values for either i_start or i_length as expr tends to run forever in these cases.
index string character-list
Report the first position in string at which any one of the characters in character-list matches a character in string.
length string
Return the length (that is, the number of characters) of string.

Trying History 

$ expr sbustr 'asdfaffasdfasdfsaf' 1 5
expr: syntax error
$ expr substr asfasdf 1 3
asf

— '' don't work, without it work

$ expr substr ############ 1 3
expr: syntax error
$ expr substr "############" 1 3
###

— without quote wont't work, with "" works

$ expr substr "############" 1 30
############

— doesn't matter over-want

$ expr substr "asdfsadf" 1 5
asdfs

— with "", always works

$ expr length asfasdf
7

— and you can get lenght too.

documented on: Mon 07-12-99 13:26:07