1837078 Members
2574 Online
110112 Solutions
New Discussion

Re: df command

 
SOLVED
Go to solution
kholikt
Super Advisor

df command

Hi,

I am using df -k to show all the disk space and usage of the filesystem. Is there anyway that I can display the disk space in MB format rathan KB
abc
7 REPLIES 7
Steven E. Protter
Exalted Contributor
Solution

Re: df command

This will do it.

modify this which parses bdf output.

#!/usr/bin/ksh

echo "Filesystem Mbytes used avail %used Mounted on"

bdf $1 | grep -v Filesystem | awk '{ printf("%s %10d %10d %10d %4s %s\n",$1,$2/1024,$3/1024,$4/1024,$5,$6)}'


#!/usr/bin/ksh

echo "Filesystem Mbytes used avail %used Mounted on"

df -k $1 | grep -v Filesystem | awk '{ printf("%s %10d %10d %10d %4s %s\n",$1,$2/1024,$3/1024,$4/1024,$5,$6)}'


You have to mess with it so that it gets the kb figure divided by 1024. It can be done.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Steven E. Protter
Exalted Contributor

Re: df command

actually i was confused. I was thinking about the du command.

I suppose with enough contortions my poorly explained post can be useful.

LOL

SEP@conference.my.pillow

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Shaikh Imran
Honored Contributor

Re: df command

Hi,
what is the O.S.
In Hp try bdf or
in Linux try

df -H

Reg
I'll sleep when i am dead.
Bill Hassell
Honored Contributor

Re: df command

I think you'll find bdf much more useful than df -k. And the attached script is called bdfmegs which will report everything in megs (try the -v option)


Bill Hassell, sysadmin
kholikt
Super Advisor

Re: df command

Hi,

Thanks for the reply I have notice your script is very useful but not easy to parse

echo "Filesystem Mbytes used avail %used Mounted on"

df -k $1 | grep -v Filesystem | awk '{ printf("%s %10d %10d %10d %4s %s\n",$1,$2/1024,$3/1024,$4/1024,$5,$6)}'

I need to convert the output to a CSV file but the output simply generate too much spaces in between the field.


abc
Fabio Ettore
Honored Contributor

Re: df command

Hi,

I get confuse when you say disk space because it is not equal to filesystem space.
Anyway bdf is the best command in order to see the filesystem space (total size, used and available space).
Anyway the best command in order to see the used space is 'du -sk'; option -k stands for Kbytes. It is more reliable about the used space of a filesystem than bdf.

HTH.

Best regards,
Ettore
WISH? IMPROVEMENT!
Shyjith P K
Frequent Advisor

Re: df command

Hi,

If you want to see the file system size in MB, you can use lvdisplay. For finding out freespace, used space, available etc. bdf is best.

Cheers
Shyjith