当我运行时ls -l
,显示以下内容:
>: ls -l
total 320
-rw-r--r-- 1 foo staff 633 5 Apr 13:23 A.class
-rw-r--r-- 1 foo staff 296 5 Apr 13:24 A.java
...
代表什么意思total
?尺寸?如果有,尺寸是多少?
答案1
它是从每个文件结构的和元素获得的块总数(通常每个 POSIX 为 512 字节;有关环境变量man ls
的详细信息,请参阅 参考资料)。因此,它不是递归的,也不会因“稀疏”文件而变得臃肿。$BLOCKSIZE
st_blocks
st_blocksize
stat()
答案2
从man 1 ls
Mac OS X 10.6.7 开始,特别是标题为“长格式”的部分
In addition, for each directory whose contents are
displayed, the total number of 512-byte blocks used by the files in the directory is
displayed on a line by itself, immediately before the information for the files in
the directory.