在linux下查看文件夹和文件大小
1.df命令可以显示目前所有文件系统的可用空间及使用情形 [1].Command:
df -h Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00 20G 4.1G 15G 23% /
/dev/mapper/VolGroup00-data 242G 124G 116G 52% /data0
...
immdb2:9421 3.0T 503G 2.5T 17% /mnt/mfs
参数 -h 表示使用「Human-readable」的输出,也就是在档案系统大小使用 GB、MB 等易读的格式。
2.查询文件或文件夹的磁盘使用空间
[1].Command:
du -h 该命令用户统计文件大小相加,在当前目录下各子目录文件相加的结果,形如
1.9G ./communication
180K ./file/2011-12-06
244K ./file
36K ./meeting/2011-12-06
44K ./meeting
1.2G ./action/2011-12-06
1.2G ./action
...
11G . .
[2].Command:
du -h [-path],获取指定目录下各子子目录文件相加的结果,形如
du -h ~
1.2G /u/imm/push/logs/2011-12-05
2.2G /u/imm/push/logs/2011-11-24
2.1G /u/imm/push/logs/2011-11-19
257M /u/imm/push/logs/2011-10-15
1.8G /u/imm/push/logs/2011-11-16
1.4G /u/imm/push/logs/2011-11-07
102G /u/imm
[3].Command:
du -h [-path/*],获取某指定目录下各个文件的大小,形如
du -h 2011-12-06/*.log
3.3M 2011-12-06/job.2011-12-06-00-0.log
3.2M 2011-12-06/job.2011-12-06-01-0.log
3.2M 2011-12-06/job.2011-12-06-02-0.log
3.2M 2011-12-06/job.2011-12-06-03-0.log
3.2M 2011-12-06/job.2011-12-06-04-0.log
3.2M 2011-12-06/job.2011-12-06-05-0.log
3.3M 2011-12-06/job.2011-12-06-06-0.log
3.3M 2011-12-06/job.2011-12-06-07-0.log
3.3M 2011-12-06/job.2011-12-06-08-0.log