macOS Mojave version 10.14.1 bash-3.2 expr: syntax error

こ雲淡風輕ζ 提交于 2021-02-05 08:13:29

问题


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, or match produces undefined results. In this version of expr, 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!