开发者

How can I find out total disk space occupied by a certain user?

How can I find total disk space occupie开发者_JS百科d by a certain user, say located in /home/Mary? What function is available in Perl to know this?


Perl has Filesys::DiskUsage for that. There is just one downside, it doesn't take the size of the directories while counting. Only the size of the files.

use Filesys::DiskUsage qw/du/;
$size = du ( { 'sector-size' => 1024 } , { 'human-readable' => 1 } , qw%/home/Mary% );
print "Total size: $size\n";


if Perl is not a must, you can use shell commands

find /home -user "Mary" -type f -printf "%s\n" | awk '{sum+=$1}END{print sum" bytes"}'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜