du

display disk usage statistics

Posted by kunnan on April 24, 2018

前言

du 、df 、sort 常常一起结合使用,我经常使用它进行文件清理之前的分析之中。

df : display free disk space

  • man df
    The following options are available:
     -h      "Human-readable" output.  Use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte and Petabyte in order to reduce the number of digits to three or less using base 2 for sizes.
     -m      Use 1048576-byte (1-Mbyte) blocks rather than the default.  Note that this overrides the BLOCKSIZE specification from the environment.
SEE ALSO
     lsvfs(1), quota(1), fstatfs(2), getfsstat(2), statfs(2), getmntinfo(3), compat(5), fstab(5), mount(8), quot(8)
  • df -h
<!-- -h, --human-readable  print sizes in human readable format (e.g., 1K 234M 2G) -->

iPhone:/private/var/MobileAsset/Assets root# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/disk0s1s1  3.8G  3.5G  278M  93% /
devfs            52K   52K     0 100% /dev
/dev/disk0s1s2   26G  2.0G   24G   8% /private/var
/dev/disk4      236M   69M  167M  30% /Developer

 这个参数和sort 的-h 参数意义是一样的
 
  • df -m
iPhone:/var/Keychains root# df -m
Filesystem     1M-blocks  Used Available Use% Mounted on
/dev/disk0s1s1      3644  3397       211  95% /
devfs                  1     1         0 100% /dev
/dev/disk0s1s2     26597  2058     24540   8% /private/var
/dev/disk4           236    69       167  30% /Developer

du: display disk usage statistics

  • man du
    The options are as follows:
     -h      "Human-readable" output.  Use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte and Petabyte.
     -s      Display an entry for each specified file.  (Equivalent to -d 0)
  • which are the larger caches.
In the terminal run du -s /Library/Caches/* | sort -n
  • du -sh *
iPhone:~/Library/Caches root# du -sh * |sort -hr
87M	com.apple.coresymbolicationd
46M	com.apple.pipelined
20M	locationd
1.2M	Backup

see also

  • df(1), fts(3), compat(5), symlink(7), quot(8)
  • Terminal
An Apple app that comes with macOS. 
Terminal provides a window with a command line where you can type commands for the computer’s operating system to perform. 
Terminal is a type of program called a “terminal emulator” commonly found on UNIX-based computers.
/Users/devzkn/bin/knpost du display disk usage statistics -t Terminal
#原来""的参数,需要自己加上""

转载请注明: > du