为什么 ls 和 ls -l linux 命令之间的计数不同?

Why count differs between ls and ls -l linux command?

我有一个包含多个文件的目录,需要检查其中存在的文件数。

我尝试了以下两个命令:

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

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

我想知道这两个命令中发生的变化。

来自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 添加 header 行说明文件的 "total" 大小:

$ 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
.......