For locating the first position of a character in a string we can use expr command.

Pham Quỳnh

New member
For locating the first position of a character in a string we can use expr command.
A. True
B. False
 
Answer: a
Explanation: expr command can also locate the first occurrence of character inside a string. For example, to locate the position of character d in the string ‘abdullah’, we have to count the number of characters which are not ‘d’ ([^d]*),
Code:
$ str=abdullah ; expr “$str”  :  ‘[^d]*d’
3
 

Tìm kiếm

Back
Top