-
-
Save un33k/1006853 to your computer and use it in GitHub Desktop.
Directory information cleaned up for dispaly
This file contains 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
#!/bin/sh | |
# github:norm:homedir:bin/df | |
# -*- Mode: Perl; tab-width: 4; indent-tabs-mode: nil; -*- | |
# | |
# Present the output of `df` in a more understandable fashion. | |
# Save this gist as df and put it on your path | |
/bin/df -h "$@" 2>/dev/null | perl -e ' | |
$prefix = <>; | |
$longest_fs = 20; | |
while ( <> ) { | |
m{ | |
^ | |
( [\S+\s]+? ) \s+ # Filesystem | |
(\S+) \s+ # Size | |
(\S+) \s+ # Used | |
(\S+) \s+ # Avail | |
(\S+) \s+ # Capacity (%) | |
(/.*) # Mounted on | |
$ | |
}x; | |
push @fs, [ $6, $2, $3, $4, $5 ]; | |
$longest_fs = length( $6 ) if length $6 > $longest_fs; | |
} | |
$tmpl = "%-${longest_fs}s %9s %9s %9s %9s\n"; | |
printf $tmpl, "Mounted on", qw( Size Used Avail Capacity ); | |
foreach my $fs ( @fs ) { | |
printf $tmpl, @{ $fs }; | |
} | |
' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment