[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: Blocks verses Bytes,Mbytes etc
- From: Harry Putnam <hgp sbcglobal net>
- To: shrike-list redhat com
- Subject: Re: Blocks verses Bytes,Mbytes etc
- Date: Tue, 29 Apr 2003 20:33:54 -0700
In case anyone should want to do this quickly here is a clumsy little
perl script that does it. It'd have to be reworked if used against
more than one disk at once as in fdisk -l. Or with other versions of
fdisk.
cat fdiskcnv
#!/usr/bin/perl -w
# Keywords: fdiskcnv - designed to convert fdisk -l output to approx.
# MB equivalents. Script Runs `fdisk -l' inside perl and converts
# the block values to Mbyte values in a second printout.
# Apr 29 2003 2
# &&
$cmd = 'fdisk -l';
open(FDISKL,"$cmd |");
while(<FDISKL>){
print;
chomp;
my $line = $_;
if(/^\/dev\//){
$readem = "TRUE";
}
if(!/^\/dev\//){
$readem = '';
}
if ($readem && /\s+\*\s+/){
## if we see the asterisk grab field5
## and get rid of any + signs by making + a split field
($fld0,$fld4) = (split(/\s+|\+/))[0,4];
$var = sprintf "%-12s %s %.2f\n","$fld0 " , "MB" , ($fld4 / 1024);
push @MB_ar, "$var";
}elsif($readem && $line !~ /\*/){
($fld0, $fld3) = (split(/\s+|\+/))[0,3];
$var = sprintf "%-12s %s %.2f\n","$fld0 ", "MB" , ($fld3 / 1024);
push @MB_ar, "$var";
}
}
close(FDISKL);
print "\n== Approximate Mbyte equivalents ====\n\n";
for(@MB_ar){
print;
}
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]