Don't parse ls
it's bad juju. My first start would be - use perl
:
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dumper;
for ( grep { -d } glob ( "*") ) {
print join ( "\t", $_, -s, (stat)[9] ),"\n";
}
But this of course, just takes the inode side of the directory, which is probably not what you want. So instead ... actually our easiest might actually be to call du
anyway.
for my $dir ( grep { -d } glob ( "*") ) {
print join ( "\t", (stat $dir)[9], `du -sh $dir`, );
}
Or perhaps making use of the Filesys::DiskUsage
module.
But as a one liner:
perl -e 'for ( grep {-d} glob ( "*" ) ) { print join "\t", (stat)[9], `du -sh $_` }'
Edit: With formatted timestamps:
perl -MTime::Piece -e 'for ( grep {-d} glob ( "*" ) ) { print join "\t", Time::Piece->new((stat)[9])->strftime("%Y-%m-%d"), `du -sh $_` }'
Edit: Version older than 5.9.5 (which you should really consider upgrading, given it's well past EOL):
perl -MPOSIX -e 'for ( grep {-d} glob ( "*" ) ) { print join "\t", strftime("%Y-%m-%d",gmtime((stat)[9]))), `du -sh $_` }'
ls
style "directory size"? – Sobrique Dec 22 '15 at 12:35