I wrote this b/c of a lack of a megabyte option in my df (on OpenBSD 2.8)
not exactly ground breaking, but (somewhat) useful ;p
#!/usr/bin/perl # # du that will show listing like df -h in mb. # $pwd = `pwd`; @crap = split(/ /, `du -sk`); foreach $turd (@crap) { $turd =~ s/\s//ig; $turd =~ s/\.//ig; $turd =~ s/\n//ig; $log = ($turd/1024); $floater = ($log/1024); printf "%10.2f Kbytes \n%7.2f MB's \n%4.3f GB's \nin $pwd",$turd, $log +, $floater; }

Edited 2001-03-09 by mirod: added <code> tags

Replies are listed 'Best First'.
Re: df -mb
by robobunny (Friar) on Feb 27, 2002 at 20:22 UTC
    i dunno what df -h does (since it doesn't seem to exist anywhere except BSD), but i put together a little front end for df -k that will reformat it in MB. it seems to work for solaris, linux and tru64.
    use strict; my $args = join(" ", @ARGV); open(D, "df -k $args |") or die "Unable to run df! $!"; my @line = split(" ", <D>); exit unless(defined(@line)); $line[1] = "mbytes"; $line[3] = "avail"; printf "%-20s %7s %7s %7s %8s %s\n", @line; while(@line = split(" ", <D>)) { for(1,2,3) { $line[$_] = $line[$_] >> 10; } printf "%-20s %7s %7s %7s %8s %s\n", @line; } close(D);