为什么ls和ls -l linux命令之间的计数不同? [英] Why count differs between ls and ls -l linux command?

查看:362
本文介绍了为什么ls和ls -l linux命令之间的计数不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目录中包含文件数量,需要检查其中的文件数量.

I had a directory with number of files and need to check the count of files present in it.

我尝试了以下两个命令:

I tried the following two commands:

ls | wc -l
ls -l | wc -l

,发现使用这两个命令时存在差异. (即,与第一个命令相比,第二个命令的使用量更大.)

and found there are differences while using both commands. (ie. number of files is greater in the usage of second command while comparing to the first command.)

我想知道两个命令中发生的更改.

I would like to know the changes happening in the both commands.

推荐答案

来自man ls:

-l      (The lowercase letter ``ell''.)  List in long format.  (See below.)  If the output is to a terminal, a total sum for all the file sizes is output on a line before the
         long listing.

因此ls -l添加标题行,指出文件的总"大小:

So ls -l adds a header line stating the "total" size of files:

$ ls -l /
total 65
-r--r--r--   1 root  wheel  6197 May 11 21:57 COPYRIGHT
drwxr-xr-x   2 root  wheel  1024 Jun  1 16:02 bin
drwxr-xr-x   9 root  wheel  1536 Jun  1 16:02 boot
dr-xr-xr-x   8 root  wheel   512 Jul  7 20:16 dev
.......

这篇关于为什么ls和ls -l linux命令之间的计数不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆