为什么在shell循环中单行写完;
后没有字符do
?
这就是我的意思。多行编写时,for
循环看起来像:
$ for i in $(jot 2)
> do
> echo $i
> done
并在一行上:
$ for i in $(jot 2); do echo $i; done
除该行外,所有折叠行都在;
其后得到a ,如果包含,则是错误的。某人可能比我聪明得多,这决定这样做是有原因的,这是正确的,但我不知道原因是什么。对我来说似乎不一致。do
;
用相同的while
循环了。
$ while something
> do
> anotherthing
> done
$ while something; do anotherthing; done
while
/ 后面for
都没有分号。