为啥ls -d */能列出所有目录

ls -F会在目录名后面加/:

  -F, --classify[=WHEN] append indicator (one of */=>@|) to entries WHEN

但ls -d */是因为bash的expansion.

我们可以写个 ls.sh,其 echo $*

或 t="*/"; echo $t 来证实这一点。

echo "*/" 输出 */

echo */ 的输出和 t="*/"; echo $t一样。

The order of expansions is: brace expansion; tilde (~) expansion, parameter and variable expansion, arithmetic expansion, and command substitution (done in a left-to-right fashion); word splitting; filename expansion; and quote removal.