为什么 ${#$2} 不起作用?
Why doesn't ${#$2} work?
我在一个小 bash 函数中有这一行:
if [ ${#} -lt 25 ]; then
但是它给我Bad substitution
上了${#}
。我在那里做错了什么?我正在尝试获取第二个命令行参数的字符长度。我该怎么做?
参数名称是2
,不是</code>。</p>
<pre><code>if [ ${#2} -lt 25 ]; then
我在一个小 bash 函数中有这一行:
if [ ${#} -lt 25 ]; then
但是它给我Bad substitution
上了${#}
。我在那里做错了什么?我正在尝试获取第二个命令行参数的字符长度。我该怎么做?
参数名称是2
,不是</code>。</p>
<pre><code>if [ ${#2} -lt 25 ]; then