I meet such error:
expr: syntax error
and my script is:
#!/bin/bash
echo `expr index "sarasara" a`
how to fix it.
$ man expr
gives this at the end:
According to the POSIX standard, the use of string arguments
length
,substr
,index
, ormatch
produces undefined results. In this version ofexpr
, these arguments are treated just as their respective string values.
In other words, macOS' expr
does not support index
.