问题
I meet such error:
expr: syntax error
and my script is:
#!/bin/bash
echo `expr index "sarasara" a`
how to fix it.
回答1:
$ man expr gives this at the end:
According to the POSIX standard, the use of string arguments
length,substr,index, ormatchproduces 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.
来源:https://stackoverflow.com/questions/53701873/macos-mojave-version-10-14-1-bash-3-2-expr-syntax-error