The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Increasing screen display size sellafrica1 AIX 0 05-08-2008 11:09 AM
display filesystem size that cross 75% as used HAA Shell Programming and Scripting 2 04-24-2007 05:56 AM
Display size shaan_dmp UNIX for Dummies Questions & Answers 1 02-13-2007 09:16 AM
Display Directory Size - DF? t4st33@mac.com UNIX for Dummies Questions & Answers 3 01-11-2007 02:12 AM
What's the easiest way to display system cpu, memory, # drives/size ?? eyounes UNIX for Advanced & Expert Users 4 03-12-2002 08:31 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-23-2008
chebarbudo's Avatar
chebarbudo chebarbudo is offline
Registered User
  
 

Join Date: Nov 2008
Location: various
Posts: 188
Display directory size

Hi all,

Is there any built in function that can display the content of a directory showing the size of directories?
I want to see the content of a directory without recursion. I don't want to see the content of all subdirectories.
I want to see the contained files with their size and the contained directories with their total size (including everything they contain).

1) I cannot get ls to do that.
2) With du, I can only get either the total size of one directory or the total size of all subdirectories (even several levels under).

Thanks in advance
Santiago

Here is an example of a directory tree with what I get with ls, then what I get with du and finally what I'd like to get:
Code:
~$ ls -lR
.:
-rw-r--r-- 1 santiago santiago   88 2008-11-23 10:34 file
drwxr-xr-x 4 santiago santiago 4096 2008-11-23 10:34 folderA
drwxr-xr-x 2 santiago santiago 4096 2008-11-23 10:35 folderB

./folderA:
-rw-r--r-- 1 santiago santiago   31 2008-11-23 10:34 fileA
drwxr-xr-x 2 santiago santiago 4096 2008-11-23 10:34 folderC
drwxr-xr-x 2 santiago santiago 4096 2008-11-23 10:34 folderD

./folderA/folderC:
-rw-r--r-- 1 santiago santiago  269 2008-11-23 10:34 fileC

./folderA/folderD:
-rw-r--r-- 1 santiago santiago  509 2008-11-23 10:34 fileD

./folderB:
-rw-r--r-- 1 santiago santiago  623 2008-11-23 10:35 fileB

~$ du
623    ./folderB
269    ./folderA/folderC
509    ./folderA/folderD
809    ./folderA
1520   .

~$ whatidlike
file       88
folderA   809
folderB   623
  #2 (permalink)  
Old 11-23-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,910
Did you try:

Code:
du -s <glob>
For example:

Code:
$ ls -l
total 10220
drwxr-xr-x+  7 sysadmin None       0 Nov  3 13:30 ast
drwxr-xr-x+  2 sysadmin None       0 Nov  3 11:56 nawk
drwxr-xr-x+ 13 sysadmin None       0 Nov  3 11:26 zsh-4.3.8
-rwx------+  1 sysadmin None 2570984 Nov  3 11:15 zsh-4.3.8-doc.tar.bz2
-rwx------+  1 sysadmin None 2656376 Nov  3 11:15 zsh-4.3.8.tar.bz2
drwxr-xr-x+ 13 sysadmin None       0 Nov  3 13:23 zsh-4.3.9
-rw-r--r--   1 sysadmin None 2570995 Nov  3 13:15 zsh-4.3.9-doc.tar.bz2
-rw-r--r--   1 sysadmin None 2659602 Nov  3 13:17 zsh-4.3.9.tar.bz2
$ du -ks *
138639  ast
1331    nawk
26518   zsh-4.3.8
2512    zsh-4.3.8-doc.tar.bz2
2596    zsh-4.3.8.tar.bz2
26534   zsh-4.3.9
2512    zsh-4.3.9-doc.tar.bz2
2600    zsh-4.3.9.tar.bz2
  #3 (permalink)  
Old 11-26-2008
Reboot's Avatar
Reboot Reboot is offline
Registered User
  
 

Join Date: Sep 2008
Location: Asia Pecific.
Posts: 31
Quote:
Originally Posted by radoulov View Post
Did you try:

Code:
du -s <glob>
For example:

Code:
$ ls -l
total 10220
drwxr-xr-x+  7 sysadmin None       0 Nov  3 13:30 ast
drwxr-xr-x+  2 sysadmin None       0 Nov  3 11:56 nawk
drwxr-xr-x+ 13 sysadmin None       0 Nov  3 11:26 zsh-4.3.8
-rwx------+  1 sysadmin None 2570984 Nov  3 11:15 zsh-4.3.8-doc.tar.bz2
-rwx------+  1 sysadmin None 2656376 Nov  3 11:15 zsh-4.3.8.tar.bz2
drwxr-xr-x+ 13 sysadmin None       0 Nov  3 13:23 zsh-4.3.9
-rw-r--r--   1 sysadmin None 2570995 Nov  3 13:15 zsh-4.3.9-doc.tar.bz2
-rw-r--r--   1 sysadmin None 2659602 Nov  3 13:17 zsh-4.3.9.tar.bz2
$ du -ks *
138639  ast
1331    nawk
26518   zsh-4.3.8
2512    zsh-4.3.8-doc.tar.bz2
2596    zsh-4.3.8.tar.bz2
26534   zsh-4.3.9
2512    zsh-4.3.9-doc.tar.bz2
2600    zsh-4.3.9.tar.bz2

You can also use :

#du -sh *

it will give you batter o/p...
  #4 (permalink)  
Old 11-26-2008
chebarbudo's Avatar
chebarbudo chebarbudo is offline
Registered User
  
 

Join Date: Nov 2008
Location: various
Posts: 188
Quote:
Originally Posted by Reboot View Post
it will give you batter o/p...
Thanks Reboot,
What is o/p?

Actually, I don't like the switch h because it makes it impossible to visually compare sizes.
  #5 (permalink)  
Old 11-26-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,910
Quote:
Originally Posted by Reboot View Post
You can also use :

#du -sh *

it will give you batter o/p...
... if your implementation of du supports it:

Code:
$ du -hs *
du: illegal option -- h
usage: du [-a][-d][-k][-r][-o|-s][-L] [file ...]
/usr/ccs/bin/what /usr/bin/du
/usr/bin/du:
        SunOS 5.8 Generic 109803-01 June 2000
$ /usr/xpg4/bin/du -hs
/usr/xpg4/bin/du: illegal option -- h
usage: du [-a][-k][-r][-s][-x] [file ...]
or:

Code:
$ du -hs *
du: illegal option -- h
usage: du [-a|-s] [-kbrx] [-t type] [name ...]
$ what /usr/bin/du
/usr/bin/du:
         $Revision: B.11.11_LR
         Thu Oct 26 23:49:27 PDT 2000 $
Quote:
What is o/p?
output, I suppose ...
  #6 (permalink)  
Old 11-23-2008
chebarbudo's Avatar
chebarbudo chebarbudo is offline
Registered User
  
 

Join Date: Nov 2008
Location: various
Posts: 188
great job.
thank you.
  #7 (permalink)  
Old 11-26-2008
chebarbudo's Avatar
chebarbudo chebarbudo is offline
Registered User
  
 

Join Date: Nov 2008
Location: various
Posts: 188
Thanks radoulov
Closed Thread

Bookmarks

Tags
directory, size

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:54 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0