macOS Mojave版本10.14.1 bash-3.2 expr:语法错误 [英] macOS Mojave version 10.14.1 bash-3.2 expr: syntax error
本文介绍了macOS Mojave版本10.14.1 bash-3.2 expr:语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我遇到这样的错误:
expr: syntax error
我的脚本是:
#!/bin/bash
echo `expr index "sarasara" a`
如何修复它.
推荐答案
$ man expr
最后给出以下内容:
根据POSIX标准,使用字符串参数
length
,substr
,index
或match
会产生不确定的结果.在这个版本中expr
,这些参数将被视为它们各自的字符串值.
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.
换句话说,macOS的 expr
不支持 index
.
In other words, macOS' expr
does not support index
.
这篇关于macOS Mojave版本10.14.1 bash-3.2 expr:语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文