Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我找到了在 shell 中使用 getopt 命令的示例脚本。
#!/bin/bash args=$(getopt ab $*) set -- $args for i; do case "$i" in -a)shift; echo "it was a";; -b)shift; echo "it was b";; esac; done
它运作良好,但我不明白变量 $i 分配在哪里。它如何知道它必须遍历 $arg。你能解释一下吗?
如此处所示,如果没有给出,则for默认为。分配您的变量。$@in seqfor i$i
for
$@
in seq
for i
$i