• 查看一下du指令的说明:

      1. [root@master ~]# hadoop fs -help du
      2. -du [-s] [-h] <path> ... :
      3. Show the amount of space(显示空间大小), in bytes(单位:bytes), used by the files that match the specified
      4. file pattern. The following flags are optional:
      5. -s (显示文件夹的总大小,不显示子文件情况)Rather than showing the size of each individual file that matches the
      6. pattern, shows the total (summary) size.
      7. -h (换一种单位,方便显示)Formats the sizes of files in a human-readable fashion rather than a number
      8. of bytes.
      9. Note that, even without the -s option, this only shows size summaries one level
      10. deep into a directory.
      11. The output is in the form
      12. size name(full path)
    • 演示:

      1. hadoop fs -du /mz
      2. hadoop fs -du -s -h /mz

      15.统计文件夹大小 - 图1