Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Unix Operating Systems > Debian Linux > Debian Linux support

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-01-2008, 09:18 AM
Davoud
 
Posts: n/a
Default Newbie Needs one Command

I need to find a Linux/Unix command that will display a list of all of
the directories, visible and hidden, on a hard drive, and the sizes of
those directories. I *do* *not* want to see a list of the half million
of so files on the drive, just directories. I've asked this question on
other Unix and Linux forums and had all sorts of good people trying to
be helpful, but no workable answers. Is this not doable, perhaps?

TIA!

Davoud

--
usenet *at* davidillig dawt com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-01-2008, 09:18 AM
Dan C
 
Posts: n/a
Default Re: Newbie Needs one Command

On Fri, 01 Feb 2008 03:37:53 +0000, Davoud wrote:

> I need to find a Linux/Unix command that will display a list of all of
> the directories, visible and hidden, on a hard drive, and the sizes of
> those directories. I *do* *not* want to see a list of the half million
> of so files on the drive, just directories. I've asked this question on
> other Unix and Linux forums and had all sorts of good people trying to
> be helpful, but no workable answers. Is this not doable, perhaps?


Sure it's doable. Here's a script:
Save it as "dt" (or whatever you'd like), make it executable, and enjoy.


#!/bin/bash

# Script Name: Directory Totals
# Purpose: List the total sizes of directories

TempFile="${HOME}/.Directory_Totals"

clear

if [ "$1" == "" ]; then

UseDir=$(pwd)

else

if [ -d "$1" ]; then

UseDir="$1"

else

echo "PROBLEM:"
echo "The directory \"$1\" does not exist !"
echo
exit 1

fi

fi

pushd "${UseDir}" >/dev/null

{

echo "Directory Totals: ${UseDir}"
echo

echo "#!/bin/bash" >${TempFile}
echo "du --one-file-system --human-readable --summarize --total -- " `\ls -A |awk '{ print "\""$0"\"" }'` >>${TempFile}
chmod u+x ${TempFile}
${TempFile}
rm -f ${TempFile}

echo

} 2>/dev/null |more

popd "${UseDir}" >/dev/null

# EOF


--
"Ubuntu" -- an African word, meaning "Slackware is too hard for me".

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-01-2008, 09:18 AM
ray
 
Posts: n/a
Default Re: Newbie Needs one Command

On Fri, 01 Feb 2008 03:37:53 +0000, Davoud wrote:

> I need to find a Linux/Unix command that will display a list of all of
> the directories, visible and hidden, on a hard drive, and the sizes of
> those directories. I *do* *not* want to see a list of the half million
> of so files on the drive, just directories. I've asked this question on
> other Unix and Linux forums and had all sorts of good people trying to
> be helpful, but no workable answers. Is this not doable, perhaps?
>
> TIA!
>
> Davoud


So, what do you want that 'du' does not supply?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-01-2008, 09:18 AM
John Hasler
 
Posts: n/a
Default Re: Newbie Needs one Command

Davoud writes:
> I need to find a Linux/Unix command that will display a list of all of
> the directories, visible and hidden, on a hard drive, and the sizes of
> those directories.


Assuming that by "hard drive" you actually mean "file system", try:

/bin/ls -lRA /path/to/filesystem | grep '^d' | awk -F ' ' -- '{print $8 FS $5}'

No doubt someone will now demonstrate how to do this more elegantly in
Perl, but grep and awk need a little exercise now and then.

If by "hard drive" you do not mean "file system" you need to tell us what
you do mean. You should also clarify what you mean by the "size" of a
directory. You might also want to tell us what problem you are trying to
solve: there may be an easier way.

--
John Hasler
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-01-2008, 09:18 AM
Spinner
 
Posts: n/a
Default Re: Newbie Needs one Command

On Fri, 01 Feb 2008 03:37:53 +0000, Davoud wrote:

> I need to find a Linux/Unix command that will display a list of all of
> the directories, visible and hidden, on a hard drive, and the sizes of
> those directories. I *do* *not* want to see a list of the half million
> of so files on the drive, just directories. I've asked this question on
> other Unix and Linux forums and had all sorts of good people trying to
> be helpful, but no workable answers. Is this not doable, perhaps?


du is the standard tool for this.

In a terminal:

du -hc <startpath>

Since you want to see all directories starting from the root, you'd
use "/" for the startpath. Also, since only root can see some system
directories and directories that some users have excluded other users
from seeing, you need to use sudo:

sudo du -hc /

You probably want to browse the list. For that use:

sudo du -hc / | less

less is a program for reading files or output generated by other
programs. The vertical bar means to send the output of du to
less. Inside less, use the arrow keys and pageup-pagedown to navigate,
press "q" to quit.

If you want to send du's output to a text file named dirs.txt, use:

sudo du -hc >~/dirs.txt

du has a many command-line options you may find useful. Run "man du"
in a terminal for info. Press 'q' to exit the mapage.

You may also want to try "ncdu". Unlike du which just prints out one
long list, ncdu lets you navigate through the directory
structure. Since ncdu has its own display routines you should NOT send
its output to less. Just use it like this:

sudo ncdu /

For further info, run "man ncdu" after installing it (ncdu should be
in the repositories).
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-01-2008, 09:18 AM
jellybean stonerfish
 
Posts: n/a
Default Re: Newbie Needs one Command

On Fri, 01 Feb 2008 03:37:53 +0000, Davoud wrote:

> I need to find a Linux/Unix command that will display a list of all of
> the directories, visible and hidden, on a hard drive, and the sizes of
> those directories. I *do* *not* want to see a list of the half million
> of so files on the drive, just directories. I've asked this question on
> other Unix and Linux forums and had all sorts of good people trying to
> be helpful, but no workable answers. Is this not doable, perhaps?
>
> TIA!
>
> Davoud
>


Maybe Dan C. is fooling with us, or maybe I just don't see the problem
with this one command.....

du --one-file-system /mntpoint


stonerfish
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 02-02-2008, 08:35 AM
Johnny Rebel
 
Posts: n/a
Default Re: Newbie Needs one Command

Davoud wrote:
> I need to find a Linux/Unix command that will display a list of all of
> the directories, visible and hidden, on a hard drive, and the sizes of
> those directories. I *do* *not* want to see a list of the half million
> of so files on the drive, just directories. I've asked this question on
> other Unix and Linux forums and had all sorts of good people trying to
> be helpful, but no workable answers. Is this not doable, perhaps?
>
> TIA!
>
> Davoud
>


Try the 'tree' command. -s does size, and -d does directories only.

JR.

--

Bill will have to take Linux from my cold, dead flippers.

-Tux.
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



All times are GMT. The time now is 09:20 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62