Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hello,
I try to detect the presence of a char in a string. This is korn shell.
mystring="1234-"
mychar="-"
if [ mystring includes mychar ] ; then
exist=1
else
exist=0
fiWhat should I write instead of [ mystrinf includes mychar ] ? Thanx !!
M

Here's one way ...
mystring="1234-"
mychar="-"if [ $(expr "$mystring" : ".*-") -gt 0 ] ; then
exist=1
else
exist=0
fi

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |