- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Finding out how much disk space is used in a c...
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
06-16-2008 01:32 PM
06-16-2008 01:32 PM
I'm trying to list how much disk space each directory (not mountpoint) uses.
I know about the du command, but is there a way to use that command without propagating all the way down all the directories?
I just want to list the disk usage of the directories in my current directory.
Thanks for your help,
Ryan
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2008 01:58 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2008 02:01 PM
06-16-2008 02:01 PM
Re: Finding out how much disk space is used in a certain directory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2008 02:26 PM
06-16-2008 02:26 PM
Re: Finding out how much disk space is used in a certain directory
rather than listing all directories recursively, to find out just top level directories' disk usage in your directory:
#cd /your_directory
#ll | grep ^d | awk '{system("du -sk "$9);}'
Kenan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2008 06:27 AM
06-17-2008 06:27 AM
Re: Finding out how much disk space is used in a certain directory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2008 06:36 AM
06-17-2008 06:36 AM
Re: Finding out how much disk space is used in a certain directory
> # ll | grep ^d | awk '{system("du -sk "$9);}'
> I don't understand any of that line but it works just great too.
The ouput of an 'll' is filtered to take only directories --- lines that begin with the letter "d" in the 'll' mode column. The caret (^) anchors the match to the beginning of a line so the match is true or false based only on the first character there.
The 'awk' process then examines the ninth ($9) field of the 'll' output (which is the directory name) and uses that field as the argument to 'du'. To run the 'du', 'awk' spawns a new process using its 'system' function.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2008 06:41 AM
06-17-2008 06:41 AM
Re: Finding out how much disk space is used in a certain directory
>I don't understand any of that line but it works just great too.
This just lists all of the files in your current directory, then selects lines starting with "d", for directories. Then invokes awk to do "du -sk" on each directory name, which is in field 9.
You can look at the stages in the pipeline:
ll | grep ^d | more
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2008 06:43 AM
06-17-2008 06:43 AM
Re: Finding out how much disk space is used in a certain directory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2008 07:38 AM
06-17-2008 07:38 AM
Re: Finding out how much disk space is used in a certain directory
Here is a thread that has links to documentation about sed, awk and perl.
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=794554
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2008 08:07 AM
06-17-2008 08:07 AM
Re: Finding out how much disk space is used in a certain directory
In addition to the books and references that Dennis pointed you toward, don't forget the excellent, free, manual collection:
http://www.gnu.org/manual/
The 'awk' guide is very good.
Regards!
...JRF...