Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: du -h, sorted

by Tanktalus (Canon)
on Feb 27, 2009 at 00:48 UTC ( [id://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!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-25 14:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found