puzzled with this output from ls

sh/bash/dash/ksh/zsh等Shell脚本
回复
DD_kid
帖子: 6
注册时间: 2007-10-24 18:59

puzzled with this output from ls

#1

帖子 DD_kid » 2011-01-24 22:48

ddkid@HP6515b-ddkid:~$ ls /usr/bin/* | wc
2805 2804 42724
ddkid@HP6515b-ddkid:~$ ls /usr/bin/ | wc
1402 1402 15052

so why is this?

ddkid@HP6515b-ddkid:~$ ls /bin/* | wc
125 125 1511
ddkid@HP6515b-ddkid:~$ ls /bin/ | wc
125 125 886

note the Line counter differs in first case, and doesn't in second case.

thx in advance.

really sorry for using english, just haven't installed scim yet.
头像
astolia
论坛版主
帖子: 6703
注册时间: 2008-09-18 13:11

Re: puzzled with this output from ls

#2

帖子 astolia » 2011-01-25 1:41

你仔细看看ls /usr/bin/*和ls /usr/bin/的差别就知道了。

/usr/bin/下面有个指向.的X11软链接,ls /usr/bin/*会把/usr/bin/X11下面的内容也输出一遍,所以实际的输出是
/usr/bin/下除X11以外的1401个文件

/usr/bin/X11:
/usr/bin/下的所有1402个文件
所以总共1401+1+1+1402=2805行,1401+0+1+1402=2804个词

如果你乐意,可以

代码: 全选

sudo ln -s /bin/. /bin/asoftlink
,/bin下的也会同样效果了
DD_kid
帖子: 6
注册时间: 2007-10-24 18:59

Re: puzzled with this output from ls

#3

帖子 DD_kid » 2011-01-25 10:09

非常感谢你详细的回答。
没有注意到这点 直到看到你的回复。
btw. 刚刚注意到论坛里还有云输入法 不错
回复