[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 21:17:38 -0700
Harry Putnam <hgp sbcglobal net> writes:
> Harry Putnam <hgp sbcglobal net> writes:
>
>> my $line = $_;
>
> Ooops. my $line should'nt have made it into the final version. Its
> useless and does nothing
I'm sorry folks... fortunately for me probably no one will try to use
the script I posted... but on the off chance they do, I should at
least post something that works. Maybe I need some coffee..
#!/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;
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 && $_ !~ /\*/){
($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]