Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^5: <p>Directory used % in Linux </p>

by FloydATC (Hermit)
on Feb 01, 2014 at 09:09 UTC ( #1072951=note: print w/ replies, xml ) Need Help??


in reply to Re^4: <p>Directory used % in Linux </p>
in thread Directory used % in Linux

As I already pointed out, the "du" tool can help you with this by reporting directory sizes but you will have to calculate percentages yourself.

Here's an example that does pretty much what you describe, go ahead and hammer it into the shape you want:

#!/usr/bin/perl use strict; use warnings; my $dir = join(' ', map { '"'.$_.'"' } @ARGV) || "*"; # Use arguments +or default to pwd my @lines = qx(du -sc $dir); # Get sizes in bytes, with total my ($total) = split(/\s/, pop @lines); # Get total number of bytes foreach my $line (@lines) { if ($line =~ /(\d+)/) { printf("%6.2f%%\t%s", $1 * 100 / $total, $line); # Prefix % } }
-- FloydATC

Time flies when you don't know what you're doing


Comment on Re^5: <p>Directory used % in Linux </p>
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1072951]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2014-09-19 23:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (151 votes), past polls