vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 |
| |||
| 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". |
| |||
| 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? |
| |||
| 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 |
| |||
| 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). |
| |||
| 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 |
| ||||
| 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. |