size of directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting size of directory
# 15  
Old 02-28-2007
Quote:
Originally Posted by redbeard_06
But it did'n return the subdirectories?
Depending your Unix version use "du -ok" if it supports the "-o" option.
# 16  
Old 02-28-2007
i use Ubuntu and it does not support this command

du: invalid option -- o
Try `du --help' for more information.
# 17  
Old 02-28-2007
Use this to get size directory wise recursively

find . -type d | xargs du -sk
# 18  
Old 02-28-2007
Thank you very much Smilie
# 19  
Old 03-01-2007
Quote:
Originally Posted by gopidesaboyina
Use this to get size directory wise recursively

find . -type d | xargs du -sk
Yes you can use this.
# 20  
Old 08-08-2008
Bug

May be this helps you .

Used to find directory sizes.... give dir. size in MB:

Code:
for i in `ls -lrt | awk '{print $9}'`; do du -ks $i  | awk '{printf "%8.2f %s\n",$1/1024,$2}'; done

EXAMPLE:
Code:
# ls -lrt
total 22
drwxr-xr-x   2 root       root            96 Sep 30  2005 lost+found
drwxrwxrwt   2 bin        bin             96 Sep 30  2005 home
dr-xr-xr-x   4 bin        bin             96 Sep 30  2005 obam
dr-xr-xr-x   2 bin        bin             96 Sep 30  2005 parmgr
dr-xr-xr-x   4 bin        bin             96 Sep 30  2005 vx
drwxr-xr-x   5 root       other           96 Sep 30  2005 stm
drwxr-xr-x   3 bin        bin             96 Sep 30  2005 X11
drwxrwxrwx   2 bin        bin             96 Sep 30  2005 news
drwxr-xr-x   2 bin        bin           1024 Sep 30  2005 yp
drwxr-xr-x   2 bin        bin             96 Sep 30  2005 rbootd
drwxr-xr-x   3 root       sys             96 Sep 30  2005 dt
dr-xr-xr-x   6 bin        bin             96 Sep 30  2005 uucp
dr-xr-xr-x  12 bin        bin           1024 Sep 30  2005 spool
dr-xr-xr-x  19 bin        bin           1024 Oct 26  2006 opt
drwxr-xr-x   2 root       sys             96 Sep 11  2007 empty
drwxrwxrwx   2 bin        bin             96 Nov 29  2007 preserve
lrwxr-xr-x   1 root       sys             19 Mar 17 17:36 symapi -> /usr/emc/API/symapi
drwxr-xr-x   2 root       root          1024 Jun 13 12:20 ECC
drwxr-xr-x   2 root       sys             96 Jun 20 12:02 emc
dr-xr-xr-x   9 bin        bin           1024 Jul  6 18:58 sam
drwxr-xr-x   2 root       root          1024 Jul  6 19:01 tombstones
dr-xr-xr-x   7 root       sys           1024 Aug  1 01:04 PSS
drwxrwxr-x   2 bin        mail          1024 Aug  6 00:12 mail
dr-xr-xr-x   3 bin        bin           1024 Aug  7 23:59 run
drwxr-xr-x  12 adm        adm           1024 Aug  8 08:47 adm
drwxrwxrwt  10 bin        bin           1024 Aug  8 10:06 tmp
eux181{root}#
eux181{root}# for i in `ls -lrt | awk '{print $9}'`; do du -ks $i  | awk '{printf "%8.2f %s\n",$1/1024,$2}'; done | sort -2
    0.00 ECC
    0.00 X11
    0.00 dt
    0.00 emc
    0.00 empty
    0.00 home
    0.00 lost+found
    0.00 news
    0.00 obam
    0.00 parmgr
    0.00 preserve
    0.00 rbootd
    0.00 run
    0.00 symapi
    0.00 uucp
    0.04 yp
    0.06 vx
    0.14 tmp
    0.38 spool
    0.73 mail
    1.27 sam
    3.47 tombstones
   11.95 PSS
   21.79 stm
 1842.21 adm
 3905.45 opt

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Ls directory size reporting byte size instead of file count

I have been searching both on Unix.com and Google and have not been able to find the answer to my question. I think it is partly because I can't come up with the right search terms. Recently, my virtual server switched storage devices and I think the problem may be related to that change.... (2 Replies)
Discussion started by: jmgibby
2 Replies

2. Shell Programming and Scripting

How to delete some of the files in the directory, if the directory size limits the specified size

To find the whole size of a particular directory i use "du -sk /dirname".. but after finding the direcory's size how do i make conditions like if the size of the dir is more than 1 GB i hav to delete some of the files inside the dir (0 Replies)
Discussion started by: shaal89
0 Replies

3. Solaris

get directory size

Hi, How to get size of particular directory? Thanks (5 Replies)
Discussion started by: cutefriend
5 Replies

4. UNIX for Dummies Questions & Answers

directory tree with directory size

find . -type d -print 2>/dev/null|awk '!/\.$/ {for (i=1;i<NF;i++){d=length($i);if ( d < 5 && i != 1 )d=5;printf("%"d"s","|")}print "---"$NF}' FS='/' Can someone explain how this works..?? How can i add directory size to be listed in the above command's output..?? (1 Reply)
Discussion started by: vikram3.r
1 Replies

5. Solaris

Directory size larger than file system size?

Hi, We currently have an Oracle database running and it is creating lots of processes in the /proc directory that are 1000M in size. The size of the /proc directory is now reading 26T. How can this be if the root file system is only 13GB? I have seen this before we an Oracle temp file... (6 Replies)
Discussion started by: sparcman
6 Replies

6. UNIX for Dummies Questions & Answers

directory size with ls -l

am I right in assuming that in unix a directory size is just information about that directory stored somewhere on the file system, and not a sum of its contents? This is because ls -l gives 1024 as my directory size, when the directory contains many gigs worth of stuff. also, is du -sk dir ... (2 Replies)
Discussion started by: JamesByars
2 Replies

7. AIX

size of directory with ls -l

hello When i do a "ls -l" in a directory (Aix 5.3), i have the result : >ls -l total 65635864 -rw-r--r-- 1 lobi system 2559909888 Feb 20 15:06 cible5.7bdat -rw-r--r-- 1 lobi system 1020098870 Feb 20 13:06 cible6.7bdat -rw-r--r-- 1 lobi system 1544789511 Feb 20 11:06 cible9.7bdat -rw-r--r--... (2 Replies)
Discussion started by: pascalbout
2 Replies

8. Programming

size of a directory

hai friends I need a program to find the size of a directory.. When i tried to get the size, it always gives the default space allocated for it. How can i findout the exact size of a directory using a c program Thanks in advance Collins (6 Replies)
Discussion started by: collins
6 Replies

9. UNIX for Dummies Questions & Answers

size of a directory?

hi, say i have the following directory structure a/b/c/d... can i do df -kt /a/b/c/d and the output will gives me the total space of the directory space in d? or the output will just be the total space of the parent directory a. hope its clear.. (2 Replies)
Discussion started by: yls177
2 Replies

10. Shell Programming and Scripting

Size of a directory

Hi, It would be of great help if anyone can tell me what is the command for getting the size of a directory. Thx a lot in advance Minaz (9 Replies)
Discussion started by: minazk
9 Replies
Login or Register to Ask a Question