Last active
September 13, 2020 19:58
-
-
Save ggorlen/c0eeb783cd601c1902b2e7831af01d13 to your computer and use it in GitHub Desktop.
sort files by size
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # list files by size recursively | |
| use strict; | |
| use warnings; | |
| use File::Find; | |
| my @seen; | |
| sub process_file { | |
| push(@seen, [-s $_, $_]) if -f $_; | |
| } | |
| find({wanted => \&process_file, no_chdir => 1}, "."); | |
| @seen = sort {@{$a}[0] <=> @{$b}[0]} @seen; | |
| for my $pair (@seen) { | |
| my $n = sprintf("%.2f", @{$pair}[0] / 1000000); | |
| print ("$n => " . (@{$pair}[1]) . "\n"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment