Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Keep It Simple, Stupid
 
PerlMonks  

Re: du -h, sorted

by Tanktalus (Canon)
on Feb 27, 2009 at 00:48 UTC ( #746722=note: print w/ replies, xml ) Need Help??


in reply to du -h, sorted

Honestly, though, I'd skip du, and just use cog's FileSys::DiskUsage module. It wouldn't be as short, but it'd be, um, a bit more readable ;-)

#! /usr/bin/perl use strict; use warnings; use Filesys::DiskUsage qw(du); use Sort::Key qw(ikeysort); my @files = @ARGV ? @ARGV : glob '*'; my %sizes = du( { 'make-hash' => 1, 'recursive' => 0, 'sector-size' => 1024, }, @files); @files = ikeysort { $sizes{$_} } keys %sizes; my %config = ( human => 1, 'truncate-readable' => 2 ); printf "%8s %s\n", Filesys::DiskUsage::_convert($sizes{$_}, %config), $_ for @files;
But, that's just me. (And look at all the other cool things you can do with Filesys::DiskUsage, or even the output format!


Comment on Re: du -h, sorted
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2014-04-19 00:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (473 votes), past polls