GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- find total space used by files older than 9 years
Operating System - HP-UX
1849065
Members
6370
Online
104041
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
back
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
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
10-11-2006 09:03 AM
10-11-2006 09:03 AM
Hello fellow system guys and gals,
Is there a command that will give the total in KB or MB of all the files passed with a find command? I thought there was an option to do this with a "du" like utility:
find /archive -type f -mtime +3287 -exec du -sk {} \;
This is wrong because it evaluates each solution instead of writing the grand total.
Greatly appreciate your response,
Kirk
Is there a command that will give the total in KB or MB of all the files passed with a find command? I thought there was an option to do this with a "du" like utility:
find /archive -type f -mtime +3287 -exec du -sk {} \;
This is wrong because it evaluates each solution instead of writing the grand total.
Greatly appreciate your response,
Kirk
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2006 09:18 AM
10-11-2006 09:18 AM
Solution
pipe the output of find to awk and sum the field that contains the file size...
# find /archive -type f -mtime +3287 -exec ll {} \; | awk '{tot+=$5}END{print tot}'
Note: change the argument of the "-exec" option from "du -sk" to "ll"
# find /archive -type f -mtime +3287 -exec ll {} \; | awk '{tot+=$5}END{print tot}'
Note: change the argument of the "-exec" option from "du -sk" to "ll"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2006 09:19 AM
10-11-2006 09:19 AM
Re: find total space used by files older than 9 years
Hi Kirk:
# find /archive -type f -mtime +3287 | xargs du -ks | perl -nalF -e 'END{print $sz};$sz+=$F[0]'
Regards!
...JRF...
# find /archive -type f -mtime +3287 | xargs du -ks | perl -nalF -e 'END{print $sz};$sz+=$F[0]'
Regards!
...JRF...
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2026 Hewlett Packard Enterprise Development LP