得到磁盘上的目录的大小和尺寸最快的方法 [英] Fastest ways to get a directory Size and Size on disk

查看:83
本文介绍了得到磁盘上的目录的大小和尺寸最快的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近<一个href=\"http://stackoverflow.com/questions/7463554/bash-how-can-i-list-out-the-size-of-each-file-and-directory-recursively-and-so/7465023#7465023\">answered一个类似的问题,但我想现在要做的是使用bash Windows的效仿目录 - >右键 - >属性功能(见图)

I recently answered to a similar question but what I'd like to do now is to emulate using bash the Windows "Directory --> right click --> Properties" function (see fig.).

我能够重现像在尺寸:在使用这个命令字节:

I was able to reproduce something like the Size: in bytes using this command:

echo $(find . -type f -printf "%s+") | sed 's/+$//g' | bc

这是相当快的,但有可能得到更快的信息(而不是查找),或做数学题快(比BC)?
此外,我会使用杜-sb 命令来模拟磁盘上的尺寸并可能另一对夫妇的发现来算的文件和目录,并效仿的包含:

which is quite fast but is it possible to get info faster (than find) or do the math faster (than bc)? In addition I would use the du -sb command to emulate the Size on Disk: and probably another couple of find to count files and directory and emulate the Contains: line.

是否有更好的方法来模仿这样的结果?

Are there better ways to emulate such results?

推荐答案

假设Cygwin的:

cd /cygdrive/c

printf "Size: %s", $( du --apparent-size -sh )
printf "Size on disk: %s", $( du  -sh )
find . -printf "%y\n" | awk '
  $1 == "d" {dirs++} 
  END {printf("Contains: %d files, %d folders\n", NR-dirs, dirs)}
'

这篇关于得到磁盘上的目录的大小和尺寸最快的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆