文件名通配是由shell在实际执行命令之前完成的(例如ls在您的情况下)。以下作品:
$ ksh --version
version sh (AT&T Research) 93t+ 2010-06-21
$ ls -l hello.account.*.001
-rw-r--r-- 1 andreas users 0 Jul 22 03:59 hello.account.sub1.001
-rw-r--r-- 1 andreas users 0 Jul 22 03:59 hello.account.sub2.001
-rw-r--r-- 1 andreas users 0 Jul 22 03:59 hello.account.sub3.001
-rw-r--r-- 1 andreas users 0 Jul 22 03:59 hello.account.sub4.001
而以下没有:
$ ls -l "hello.account.*.001"
ls: hello.account.*.001: No such file or directory
原因是在第一种情况下,shell 在执行之前扩展了文件名模式ls——ls然后会看到四个不同的文件名作为参数传递。
在第二种情况下,由于文件名模式用双引号转义,ls因此模式本身被传递(它ls不会进一步扩展 - 它会查找具有 name 的文件hello.account.*.001)