df -k to df -h


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting df -k to df -h
# 8  
Old 06-15-2008
I tested that under 5.6.0 and it worked as expected

Did you copy the source as such ? ( Sorry for asking such silly questions )

First check with '-c' option and then run
# 9  
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.
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question