- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- bdf | awk '{ sum += $2; } END { print sum; }' for ...
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
тАО04-01-2008 06:26 AM
тАО04-01-2008 06:26 AM
gives me 5.03521e+07
Not sure what that means. How can I get output in Megbytes ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-01-2008 06:33 AM
тАО04-01-2008 06:33 AM
SolutionThis is simply scientific notation. This is 5.03521 times 10 raised to the 7th power:
50,352,100
To obtain megabytes (ideally) divide by 1024/1024 or:
# bdf | awk '{ sum += $2; } END { print sum/1024/1024; }'
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-01-2008 06:37 AM
тАО04-01-2008 06:37 AM
Re: bdf | awk '{ sum += $2; } END { print sum; }' for total space in Megabytes ??
I would also direct you to this article and its links which show that the terms 'mega', 'giga', etc. become imprecise as the magnitude of numbers increase. A acccurate terminology is 'mebi'byte, here:
http://en.wikipedia.org/wiki/Mebibyte
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-01-2008 06:46 AM
тАО04-01-2008 06:46 AM
Re: bdf | awk '{ sum += $2; } END { print sum; }' for total space in Megabytes ??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-01-2008 07:02 AM
тАО04-01-2008 07:02 AM
Re: bdf | awk '{ sum += $2; } END { print sum; }' for total space in Megabytes ??
Ooops, sorry, I'm thinking giga/gibi bytes :-)
NO POINTS PLEASE!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-01-2008 08:44 AM
тАО04-01-2008 08:44 AM
Re: bdf | awk '{ sum += $2; } END { print sum; }' for total space in Megabytes ??
Now that I have had coffee and lunch, after a long night, I would suggest you amend your formatting to round your values, too. The 'printf' function accomodates this. Too, I would also instruct 'awk' to skip the first record (the header line from 'bdf') as a cleaner implementation, although in this case there is no second field in the header.
# bdf | awk 'NR>1 {sum+=$2};END {printf "%5.0f MB\n",sum/1024}'
No points are necessary for what I ahould have added the first time!
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-01-2008 01:51 PM
тАО04-01-2008 01:51 PM
Re: bdf | awk '{ sum += $2; } END { print sum; }' for total space in Megabytes ??
If BDF does the job for you, then more power to you! However, several of us run into issues with it due to the bonus line-wrapping it does for long names.
See for example:
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=542488
So you may want to build a serious script with DF looking for field $4 or "dk -k" looking for field $5 on lines with "total"
Also... you want to count NFS mounts?
Consider using bdf | awk '/^.dev/{ sum...
# The "^" anchors te search to the begin of line.
# The "." is a cheat place holder for /
fwiw,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-01-2008 06:48 PM
тАО04-01-2008 06:48 PM
Re: bdf | awk '{ sum += $2; } END { print sum; }' for total space in Megabytes ??
Usage: bdfmegs [ -glPpqstvu ] [ dir(s) or file(s) ]
where:
-g = gigabytes rather than megabytes
-l = local only (not NFS)
-p ## = highlight pct -ge ##
-P ## = same as -p but show only pct -ge ##
-q = suppress the header line and no char enhancements
-s = summary of total, used and available
-t xxxx = specifc filesystem (hfs vxfs nfs cdfs cifs autofs DevFS)
-u = usage details (return code = 0, usage text to stdout)
-v = verbose (shows FSversion, largefiles flag)
(requires read permission for mountpoint)
File(s) or dirpath(s) may be specified to limit
the output of bdfmegs as in:
bdfmegs -vlg /usr/contrib/bin /var/tmp
If bdfmegs is run as bdfgigs (ie, a link), then -g is default.
(bdfmegs ver 4.7)
Bill Hassell, sysadmin