do
Bashfor
循环语法中关键字的用途是什么?对我来说,感觉是多余的。
for i in `seq 1 2`; do echo "hi"; done
Run Code Online (Sandbox Code Playgroud)
为什么不是这样的语法?
for i in `seq 1 2`; echo "hi"; done
Run Code Online (Sandbox Code Playgroud)
我确信它确实达到了目的。我只是想学习。
我不明白为什么 * 在没有匹配项时会返回自身。这个答案表明情况确实如此,但我不明白这种行为的基本原理。为什么 * 或任何通用模式在不匹配的情况下不返回空字符串?
$ls # Look, no files
$touch a # Add a file
$echo * # Works as expected
a
$rm a # Remove the file
$echo * # Will output a '*'. Why not ''?
*
$* # Ok, * will fail, but how come the previous output?
-bash: *: command not found
$
Run Code Online (Sandbox Code Playgroud)