Unix Technical Forum

Shell command to find dir sizes under /usr

This is a discussion on Shell command to find dir sizes under /usr within the AIX Operating System forums, part of the Unix Operating Systems category; --> Hi Gurus, Newbie here. I am using AIX 5.1 I am trying to find the directory sizes of all ...


Go Back   Unix Technical Forum > Unix Operating Systems > AIX Operating System

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-05-2008, 03:17 AM
PG
 
Posts: n/a
Default Shell command to find dir sizes under /usr

Hi Gurus,

Newbie here.

I am using AIX 5.1

I am trying to find the directory sizes of all subdirectories under
/usr (or any directory). I would like a list of immidiate sub
directories of /usr with their sizes. I do not want recursive output.
Here is what i tried unsuccessfully

cd /usr
ls -1 | du -sk $1 //gives error on $1
ls -1 | du -sk {} \; //borrowed the syntax from find command, got
errors.

tried find command but could not figure out how to stop find from
descending deeper than the first level. I was gonna try

find . -type d -exec du -sk {} \;//works except it is recursive

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-05-2008, 03:17 AM
Jason Mather
 
Posts: n/a
Default Re: Shell command to find dir sizes under /usr

PG wrote:
> Hi Gurus,
>
> Newbie here.
>
> I am using AIX 5.1
>
> I am trying to find the directory sizes of all subdirectories under
> /usr (or any directory). I would like a list of immidiate sub
> directories of /usr with their sizes. I do not want recursive output.
> Here is what i tried unsuccessfully
>
> cd /usr
> ls -1 | du -sk $1 //gives error on $1
> ls -1 | du -sk {} \; //borrowed the syntax from find command, got
> errors.
>
> tried find command but could not figure out how to stop find from
> descending deeper than the first level. I was gonna try
>
> find . -type d -exec du -sk {} \;//works except it is recursive
>
> Thanks



cd /usr
for dir in `ls -l |awk '/^d/ {print $9}'` ; do du -sk $dir ; done

-- Jason
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-05-2008, 03:17 AM
Andy France
 
Posts: n/a
Default Re: Shell command to find dir sizes under /usr

PG wrote:
> Hi Gurus,
>
> Newbie here.
>
> I am using AIX 5.1
>
> I am trying to find the directory sizes of all subdirectories under
> /usr (or any directory). I would like a list of immidiate sub
> directories of /usr with their sizes. I do not want recursive output.
> Here is what i tried unsuccessfully
>
> cd /usr
> ls -1 | du -sk $1 //gives error on $1
> ls -1 | du -sk {} \; //borrowed the syntax from find command, got
> errors.
>
> tried find command but could not figure out how to stop find from
> descending deeper than the first level. I was gonna try
>
> find . -type d -exec du -sk {} \;//works except it is recursive
>
> Thanks


This works for me on AIX 5.2:

# cd /usr; du -sk */

Mind you, this does miss out on what /usr itself contains. But you did
say you wanted the subdirectories :-)

HTH
Andy (Not a guru!)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:48 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com