Operating System - Linux
1753675 Members
5169 Online
108799 Solutions
New Discussion юеВ

Re: Displaying output from df -k in GB instead of KB

 
SOLVED
Go to solution
Patrick Ware_1
Super Advisor

Re: Displaying output from df -k in GB instead of KB

Thanks Dennis for your input. I must ask, what do you mean by "RE"?
James R. Ferguson
Acclaimed Contributor

Re: Displaying output from df -k in GB instead of KB

Hi Patrick:

"RE" is a common abbreviation for Regular Expression. A more descriptive abbreviation is 'regexp'. In fact, the manpges for 'regexp(5)' provide a good introduction.

http://www.docs.hp.com/en/B2355-60105/regexp.5.html

Regular expressions exist in many languages and utilities. 'grep' is the most familiar case to many. The C language, 'awk', 'sed' and particularly Perl offer regular expressions, Perl having one of the most robust engines built naturally into it.

Regards!

...JRF...
Patrick Ware_1
Super Advisor

Re: Displaying output from df -k in GB instead of KB

Thanks all! I am now reading an AWK tutorial to drive home all the pointers you folks have given me.
Hein van den Heuvel
Honored Contributor

Re: Displaying output from df -k in GB instead of KB

>> I am now reading an AWK tutorial to drive home all the pointers you folks have given me.

Excellent! Did you already get to the chanter on arrays?


Check this out....

df -l -k | awk -f df.awk

------- df.awk --------------

BEGIN {
header["/ora"]="Oracle Filesystems";
header["/ebr"]="EBR Filesystems";
header["none"]="Flat Files";
}

END {
for (name in header) {
t = 0;
print "\n\n" header[name] "\n-------------\n";
for (j=0; j t += size[name,j];
printf ("%-20s is %5.1f Gb\n",mount[name,j],size[name,j]/1024/1024)
}
grand += t;
printf ("\nTotal %5.1f Tb\n",t/1024/1024/1024);
}
printf ("\nGrand Total %5.1f Tb\n",grand/1024/1024/1024);

}

/total/ && !/vg00/ {
kb = $(NF-3);
name = "none";
for (x in header) {
if ($1 ~ x) name = x;
}
j = lines[name]++;
mount[name,j] = $1;
size[name,j] = kb;
}

------------------

Cheers,
Hein.
Patrick Ware_1
Super Advisor

Re: Displaying output from df -k in GB instead of KB

Not yet, but this may be a good case study. Thanks!