- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Summation of file sizes in directory
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
03-25-2007 11:53 PM
03-25-2007 11:53 PM
$ du -sk * ,it gives size of individual files in k bytes.
I want to get a summation of size of all files in directory ,could you please tell the command syntax to be used.
Thanks in anticipation.
Regards
harish
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2007 11:59 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2007 12:00 AM
03-26-2007 12:00 AM
Re: Summation of file sizes in directory
for your current directory or
# du -ks directory_name
for a specific directory.
Regards.
Robert-Jan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2007 12:00 AM
03-26-2007 12:00 AM
Re: Summation of file sizes in directory
only "du -sk" without the '*' will show you the size including the subdirectories
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2007 12:54 AM
03-26-2007 12:54 AM
Re: Summation of file sizes in directory
as you have allocated 8 points to Senthils response there is room for improvement.
Although Senthils answer sums up the entries via du the result is in KB not bytes.
Also in your original spec you said files, but the current answer includes directories.
So, if you want the 'perfect' answer please provide more info on exactly what you want to sum up. Files only, current directory (with/without subdirectories), local file system only ....?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2007 03:44 AM
03-26-2007 03:44 AM
Re: Summation of file sizes in directory
In this case it was only files in directory.
It will be helpful if you can guide for sub directories as well.
Regards
harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2007 04:00 AM
03-26-2007 04:00 AM
Re: Summation of file sizes in directory
du -sk $* | \
awk '{i = i + $1; print $0;}
END {printf("---------------------\n%d KBytes\n", i);}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2007 08:31 PM
03-26-2007 08:31 PM
Re: Summation of file sizes in directory
I use the attached dsr.ksh script to gather info about dir spaces/file.
HTH,
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2007 10:16 PM
03-26-2007 10:16 PM
Re: Summation of file sizes in directory
but this should sum up sizes of files beneath a certain directory, remaining on the same filesystem (otherwise omit the -xdev).
e.g. for my /opt (chose any appealing start dir, also conversion to K, M, G or whatever ad lib)
# find /opt -xdev -type f|xargs ll|awk '$5>0{s+=$5};END{printf"%10.2f MB\n",s/2^20}'
1230.96 MB