San*_*ahu 120 unix linux shell command prompt
什么是total在输出ls -l?
$ ls -l /etc
total 3344
-rw-r--r-- 1 root root 15276 Oct 5 2004 a2ps.cfg
-rw-r--r-- 1 root root 2562 Oct 5 2004 a2ps-site.cfg
drwxr-xr-x 4 root root 4096 Feb 2 2007 acpi
-rw-r--r-- 1 root root 48 Feb 8 2008 adjtime
drwxr-xr-x 4 root root 4096 Feb 2 2007 alchemist
Run Code Online (Sandbox Code Playgroud)
Mat*_*Mat 88
您可以在ls平台的文档中找到该行的定义.对于coreutils ls(在许多Linux系统上发现的那个),可以通过info coreutils ls以下方式找到信息:
对于列出的每个目录,在文件前面加上"total BLOCKS"行,其中BLOCKS是该目录中所有文件的总磁盘分配.
Don*_*ott 44
total int = 每个文件的(physical_blocks_in_use)*physical_block_size/ls_block_size的总和.
哪里:
ls_block_size是一个任意的环境变量(通常是512或1024字节),可以通过--block-size=<int>标志打开ls,POSIXLY_CORRECT=1GNU环境变量(获得512字节单位)或-k强制1kB单位的标志自由修改 .physical_block_size是内部块接口的OS相关值,它可能连接也可能不连接到底层硬件.该值通常为512b或1k,但完全依赖于OS.它可以通过或%B上的值显示出来. 请注意,此值(几乎总是)与现代存储设备上的物理块数无关.statfstat
此数字与任何物理或有意义的指标相当分离.许多初级程序员没有文件漏洞或硬/ sym链接的经验.此外,关于此特定主题的文档几乎不存在.
"块大小"一词的脱节和模糊性是许多不同措施容易混淆的结果,而相对较深的抽象层次围绕磁盘访问.
du或ls -s)vsstatdu *在项目文件夹中运行会产生以下结果:( 注意:ls -s返回相同的结果.)
dactyl:~/p% du *
2 check.cc
2 check.h
1 DONE
3 Makefile
3 memory.cc
5 memory.h
26 p2
4 p2.cc
2 stack.cc
14 stack.h
Run Code Online (Sandbox Code Playgroud)
总计:2 + 2 + 1 + 3 + 3 + 5 + 26 + 4 + 2 + 14 = 62块
然而,当一个人运行时,stat我们会看到一组不同的值.stat在同一目录中运行会产生:
dactyl:~/p% stat * --printf="%b\t(%B)\t%n: %s bytes\n"
3 (512) check.cc: 221 bytes
3 (512) check.h: 221 bytes
1 (512) DONE: 0 bytes
5 (512) Makefile: 980 bytes
6 (512) memory.cc: 2069 bytes
10 (512) memory.h: 4219 bytes
51 (512) p2: 24884 bytes
8 (512) p2.cc: 2586 bytes
3 (512) stack.cc: 334 bytes
28 (512) stack.h: 13028 bytes
Run Code Online (Sandbox Code Playgroud)
总计: 3 + 3 + 1 + 5 + 6 + 10 + 51 + 8 + 3 + 28 = 118块
注意:您可以使用命令
stat * --printf="%b\t(%B)\t%n: %s bytes\n">(按顺序)输出块的数量(以parens为单位)这些块的大小,文件名和大小(以字节为单位),如上所示.
有两件重要的事情需要注意:
stat报告上面公式中使用的physical_blocks_in_use和physical_block_size.请注意,这些是基于OS接口的值.du提供通常被接受的物理磁盘利用率的相当准确的估计.作为参考,这是ls -l上面的目录:
dactyl:~/p% ls -l
**total 59**
-rw-r--r--. 1 dhs217 grad 221 Oct 16 2013 check.cc
-rw-r--r--. 1 dhs217 grad 221 Oct 16 2013 check.h
-rw-r--r--. 1 dhs217 grad 0 Oct 16 2013 DONE
-rw-r--r--. 1 dhs217 grad 980 Oct 16 2013 Makefile
-rw-r--r--. 1 dhs217 grad 2069 Oct 16 2013 memory.cc
-rw-r--r--. 1 dhs217 grad 4219 Oct 16 2013 memory.h
-rwxr-xr-x. 1 dhs217 grad 24884 Oct 18 2013 p2
-rw-r--r--. 1 dhs217 grad 2586 Oct 16 2013 p2.cc
-rw-r--r--. 1 dhs217 grad 334 Oct 16 2013 stack.cc
-rw-r--r--. 1 dhs217 grad 13028 Oct 16 2013 stack.h
Run Code Online (Sandbox Code Playgroud)
Dav*_*ley 26
这是列出的文件使用的文件系统块的总数,包括间接块.如果您运行ls -s相同的文件并汇总报告的数字,您将得到相同的数字.
| 归档时间: |
|
| 查看次数: |
59685 次 |
| 最近记录: |