无参数的Bash for循环
有人能解释一下为什么下面的代码在bash中是有效的,如果有的话,效果如何无参数的Bash for循环,bash,Bash,有人能解释一下为什么下面的代码在bash中是有效的,如果有的话,效果如何 表示值;做 echo美元价值 完成 据我所知,bash只是忽略了这段代码,但我不明白为什么它不会引发语法错误或其他什么?正如@Jetchisel所指出的,我们可以在shell中运行help for,查看for命令的docstring $ help for for: for NAME [in WORDS ... ] ; do COMMANDS; done Execute commands for each memb
表示值;做
echo美元价值
完成
据我所知,bash只是忽略了这段代码,但我不明白为什么它不会引发语法错误或其他什么?正如@Jetchisel所指出的,我们可以在shell中运行
help for
,查看for
命令的docstring
$ help for
for: for NAME [in WORDS ... ] ; do COMMANDS; done
Execute commands for each member in a list.
The `for' loop executes a sequence of commands for each member in a
list of items. If `in WORDS ...;' is not present, then `in "$@"' is
assumed. For each element in WORDS, NAME is set to that element, and
the COMMANDS are executed.
Exit Status:
Returns the status of the last command executed.
我不知道的部分强调如下:
[…]如果`用词…;'不存在,则假定为“$@”中的“in”。[…]
在终端中运行的帮助,尝试验证shell脚本。谢谢!你能加上这个作为答案吗?这样我就可以接受了。没关系,我把它留在这里。