[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ind=`expr index "${string}" is` -----bug
From: |
Pierre Gaston |
Subject: |
Re: ind=`expr index "${string}" is` -----bug |
Date: |
Sun, 18 Mar 2018 16:02:23 +0200 |
> From: zangwenkuo
>
> To: bug-bash@gnu.org
> when i use the fun as title (expr)
> i got a "expr: syntax error"
>
>
expr is an external tool, and expr is the one giving you an error, so it's
not a problem of "bash"
The error may be that your "expr" tool is not the gnu version and thus
doesn't support this syntax.
To get the same result you could use the pattern matching of standard expr
eg matching all the characters not in your set + one:
ind=`expr "$string" : '[^is]*.'`
with pure (ba)sh, you could use parameter expansion like:
temp=${string%%[is]*}
ind=$(( ${#temp} + 1))