- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: shell script for disk space in GB
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-16-2005 12:51 AM
тАО11-16-2005 12:51 AM
I need a shell script to find total disk space available, used and and free in terms of GB.
Thanks,
Shiv
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-16-2005 12:59 AM
тАО11-16-2005 12:59 AM
Re: shell script for disk space in GB
#!/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)}'
for GB
#!/usr/bin/ksh
echo "Filesystem Gbytes 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/1024,$5,$6)}'
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-16-2005 01:01 AM
тАО11-16-2005 01:01 AM
Solution#!/usr/bin/ksh
echo "Filesystem Gbytes used avail %used Mounted on"
bdf $1 | grep -v Filesystem | awk '{ printf("%s %10d %10d %10d %4s %s\n",$1,$2/
1024/1024,$3/1024,$4/1024/1024,$5,$6)}'
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-16-2005 01:01 AM
тАО11-16-2005 01:01 AM
Re: shell script for disk space in GB
With all due respect, you would learn a great deal more by posting *what* you have tried to create and then asking for help where you are stuck.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-16-2005 01:04 AM
тАО11-16-2005 01:04 AM
Re: shell script for disk space in GB
I got this from Patrick Wallek (attached).
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-16-2005 01:07 AM
тАО11-16-2005 01:07 AM
Re: shell script for disk space in GB
http://mirrors.develooper.com/hpux/downloads.html
di -d G
will give you filesystem information in GBs.
Filesystem Mount Gigs Used Avail %used fs Type
hth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-16-2005 11:55 AM
тАО11-16-2005 11:55 AM
Re: shell script for disk space in GB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-16-2005 12:33 PM
тАО11-16-2005 12:33 PM
Re: shell script for disk space in GB
#!/usr/bin/sh
bdf | awk '!/Filesystem/ {
s2+=$2;s3+=$3;s4+=$4;
printf("%-18s %10d %10d %10d %4s %s\n",
$1,$2/1024/1024,$3/1024/1024,$4/1024/1024,$5,$6)}
END{printf "%-18s %10d %10d %10d\n","TOTAL",
s2/1024/1024,s3/1024/1024,s4/1024/1024}'
...while not formatted to be pretty, I think this gives you want you want. Columns do not quite add up due to rounding.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-16-2005 12:58 PM
тАО11-16-2005 12:58 PM
Re: shell script for disk space in GB
I should have said (of course) that "Columns do not quite add up due to integer truncation."
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-16-2005 01:53 PM
тАО11-16-2005 01:53 PM
Re: shell script for disk space in GB
This last hack does a better job of formatting the output and replaces the printf() integers with rounded reals (via "%10.2f"). You will find that the columnar totals are much closer to their expected values.
#!/usr/bin/sh
bdf | awk '
BEGIN{printf "%-16s %10s %10s %10s %5s %s\n",
"Filesystem","GB","Used","Avail","Used","Mounted_On"};
!/Filesystem/ {
s2+=$2;s3+=$3;s4+=$4;
printf("%-16s %10.2f %10.2f %10.2f %5s %s\n",
$1,$2/1024/1024,$3/1024/1024,$4/1024/1024,$5,$6)}
END{printf "%-16s %10.2f %10.2f %10.2f\n","TOTAL",
s2/1024/1024,s3/1024/1024,s4/1024/1024}'
Regards!
...JRF...