- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to get count total size of files under dir
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
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
тАО09-16-2007 11:50 PM
тАО09-16-2007 11:50 PM
as per one requirement i need to give the total size estimates of files under certain dir.
i want some simple command which can give me the correct total size of all files in bytes.
Is there any way that i can get size in MB or GB? If there are any simple way to do this then it will be very help ful for me?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-17-2007 12:07 AM
тАО09-17-2007 12:07 AM
Re: How to get count total size of files under dir
du -sk /directory_name
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-17-2007 12:09 AM
тАО09-17-2007 12:09 AM
Re: How to get count total size of files under dir
# du -kxs /directory
...will return the total in 1K (1024) bytes
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-17-2007 12:40 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-17-2007 01:35 AM
тАО09-17-2007 01:35 AM
Re: How to get count total size of files under dir
You could do a "du -s" for the total of in the directory you are in or "du -s *" for all the the files in the directory.
sp,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-17-2007 01:41 AM
тАО09-17-2007 01:41 AM
Re: How to get count total size of files under dir
du -sk .
BR.
Ernesto
---------------------------------------------
MAN du:
NAME
du - summarize disk usage
DESCRIPTION
The du utility writes to standard output the size of the file space allocated to, and the size of the file space allocated to each subdirectory of, the file hierarchy rooted in each of the specified files. The size of the file space allocated to a file of type directory is defined as the sum total of space allocated to all files in the file hierarchy rooted in the directory plus the space allocated to the directory itself. This sum will include the space allocated to any extended attributes encountered.
Files with multiple links will be counted and written for only one entry. The directory entry that is selected in the report is unspecified. By default, file sizes are written in 512-byte units, rounded up to the next 512-byte unit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-17-2007 06:20 AM
тАО09-17-2007 06:20 AM
Re: How to get count total size of files under dir
# cd /dir
# du -sk * | sort -rn
Rgds / James
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-17-2007 10:57 PM
тАО09-17-2007 10:57 PM
Re: How to get count total size of files under dir
Thanks a ton to all.
Hi Spex,
Your Awk cmd is working fine. As JRF told du -ksx will return total in Kb, therefore can update your cmd like in place of bytes i am putting KB, please correct me if i am wrong:
$ du -skx /mydir | awk '{printf("%.2f Kbytes, %.2f mbytes, %.2f gbytes\n",$1,$1/1024,$1/1048576)}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-17-2007 11:07 PM
тАО09-17-2007 11:07 PM
Re: How to get count total size of files under dir
Rather than code your constant as 1048576 in:
# du -skx /mydir | awk '{printf("%.2f Kbytes, %.2f mbytes, %.2f gbytes\n",$1,$1/1024,$1/1048576)}'
...it is clearer to do:
## du -skx /mydir | awk '{printf("%.2f Kbytes, %.2f mbytes, %.2f gbytes\n",$1,$1/1024,$1/(1024*1024))}'
This makes the calculation much more obvious and is less likely to be wrong because of a typographical error.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-17-2007 11:50 PM
тАО09-17-2007 11:50 PM
Re: How to get count total size of files under dir
Thanks a lot. Now it is fine for me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-17-2007 11:51 PM
тАО09-17-2007 11:51 PM
Re: How to get count total size of files under dir
Thanks a lot. Now it is fine fro me.