- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Sum values
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
Forums
Discussions
Discussions
Discussions
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
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
12-02-2008 07:02 AM
12-02-2008 07:02 AM
Simple and stupid question:
I need to sum values of some files placed in some directory. I use awk to get values like exemple:
# ls -lt avbmon* | awk '{ print $5 }'
13628
13413
13413
13413
Now i have values, but i need obtain total. I try "sum" command, but i don't have succes with sintax. Can anyone help me? Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2008 07:08 AM
12-02-2008 07:08 AM
Solutionhttp://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1218175
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2008 07:10 AM
12-02-2008 07:10 AM
Re: Sum values
# ls -lt | awk 'END{printf "sum=%-3.0f\n",SUM};{SUM+=$5;print $5}'
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2008 07:16 AM
12-02-2008 07:16 AM
Re: Sum values
ls -lt avbmon* | awk 'END{printf "sum=%-3.0f\n",SUM};{SUM+=$5 /1024;print $5 }'
13628
13413
13413
13413
sum=53
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2008 07:24 AM
12-02-2008 07:24 AM
Re: Sum values
That would be KB.
For MB divide by 1024*1024 ( 1048576 )
Also, it is typically best to divide the sum, not the individual components.
Higher precision, and Fewer division (does not matter here).
If you only want the sum of the size, then drop the time sort order from -lt.
try:
ls -l avbmon* | awk 'END{printf "sum=%-3.0f\n",SUM/1048576};{SUM+=$5;print $5 }'
Hein
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2008 07:25 AM
12-02-2008 07:25 AM
Re: Sum values
To get MB, do:
# ls -lt avbmon* | awk 'END{printf "sum=%-3.2f\n",SUM/1024/1024};{SUM+=$5;print $5}'
...keep the precision as long as you can.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2008 07:42 AM
12-02-2008 07:42 AM