Sponsored Content
Full Discussion: df -k to df -h
Top Forums Shell Programming and Scripting df -k to df -h Post 302205598 by ghostdog74 on Sunday 15th of June 2008 11:32:21 PM
Old 06-16-2008
well, you can convert it to nawk
Code:
df -k | nawk '
function num_to_letter(val) {
  if (val=="1") notation = "K"
  else if (val=="2") notation = "M"
  else if (val=="3") notation = "G"
  else notation = "Error"
  return notation
}
function num_convert(v) {
  cnt=0
  CONV_FACTOR=1024
  while ( (v / CONV_FACTOR) > 1 ) {
    v /= CONV_FACTOR;
    cnt++;
  }  
  return v""num_to_letter(cnt);
}
{
    print num_convert($2)
}
'

code courtesy of matrix. I leave you to do the rest.
 
All times are GMT -4. The time now is 05:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy