Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

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?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2015-11-29 21:14 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (753 votes), past polls