Re: How to find total MB of a directory plus all subdirectories



On Thu, 2007-03-08 at 20:35 +0100, Nigel Henry wrote:
On Wednesday 07 March 2007 04:32, Bruno Wolff III wrote:
On Tue, Mar 06, 2007 at 22:01:38 +0100,

Nigel Henry <cave.dnb@xxxxxxxxxx> wrote:
This is a silly question perhaps. I have my soundfiles in a directory
named Sounds Library, this contains many subdirectories, which contain
the .wav files.

What command can I use to find out the disk space this directory is
taking up, including all the files that are in the subdirectories?

du -k

Hi Bruno. That's interesting as it lists all the subdirectories in my "Music"
directory, with their individual filesizes, and ending with the total content
of the "Music" directory. That's not usually a problem with individual
subdirectories though, as hovering the mouse over them shows the total size
of the files in them.

I have a question about du though. On the other machine where I wanted to find
out the size of my soundfiles directory, du couldn't access it because it was
named "Sounds Library" , without the quotes. I renamed it putting a hyphen
between the 2 words, and then du accessed the directory ok, but all of the
subdirectories are multi worded without any hyphens, and du didn't have any
problem with them. Any reason why du will not access the main directory
without hyphenated words, and yet has no problem with all the subdirectories?

It's not a big deal, just puzzling.

btw. The now Sounds-Library (with the hyphen) is on a separate harddrive so I
have to run du as.

du -sh /mnt/hdb5/Sounds-Library

Hi, Nigel,
The reason a command won't parse correctly with a space in the file
name is due to the tokenizer used by the shell. It cannot deal with
spaces in filenames. A space is the end of the word to the tokenizer
unless it is inside Quotes or escaped in some way. Thus the command du
xxx yyy is going to look for files xxx and then yyyy. This is true of
most systems. otherwise there would be no way to chose which way to
parse a command with several arguments, for example:
cat xxx yyy aaa bbb ccc ddd > temp.txt

In this case should the result consist of files xxx, yyy, zzz, bbb,
ccc, and ddd all being concatenated to a file called temp.txt, or should
it be xxx yyy, zzz bbb, and ccc ddd? Moreover how would an unambiguous
error message tell the operator what was wrong? What if files xxx, yyy
zzz, bbb zzz, and ddd were all present? Is this what the operator
meant?
This is why a good administrator doesn't put spaces in system control
files. It leads to ambigousity when working on the system, leading to
errors and system corruption. Typo's that would be caught might not be
if spaces are allowed into filenames.

On the other hand, once a directory is opened, the file names are read
via a special command designed for the OS, and if the OS permits spaces,
the entire file name up to the end charactor (generally control-Z or
NULL). Thus the sub directories and files will be correctly handled.
But with spaces in the names, error messages regarding parsing, or
tracing the file contents may be ambiguous to the operator. It is not
illegal to put spaces in filenames, but is should be considered a bad
practice, and avoided. But it is your system, so YMMV.

Regards,
Les H

--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list



Relevant Pages

  • Re: Need some small help on shell script - delete old files
    ... command so that it does not search subdirectories past this directory ... Please look at my original script from the first message to this ... # this is sufficiently unique in the BKPPATH ... The find command shows all files in the directory and subdirectories. ...
    (comp.unix.shell)
  • Re: Need some small help on shell script - delete old files
    ... command so that it does not search subdirectories past this directory ... The find command shows all files in the directory and subdirectories. ... gzip of $FILENAME at the end is not necessary as far as I can tell ... I am running the script and have noticed that the file names have been ...
    (comp.unix.shell)
  • Re: How to delete directory someone created in my directory
    ... I also cannot change the protections of the directory. ... This command has been superseded by the SET SECURITY/PROTECTION ... This may generate errors if it tries to delete non-empty subdirectories. ... See Help Backup /BY_OWNER to learn about setting the owner of ...
    (comp.os.vms)
  • Re: Need some small help on shell script - delete old files
    ... command so that it does not search subdirectories past this directory ... The find command shows all files in the directory and subdirectories. ... I am using your script. ... recent dump is always left un-compressed with no .gz extension. ...
    (comp.unix.shell)
  • Re: How to find total MB of a directory plus all subdirectories
    ... On Thursday 08 March 2007 20:49, Todd Zullinger wrote: ... but all of the subdirectories are ... multi worded without any hyphens, and du didn't have any problem ... without hyphenated words, and yet has no problem with all the ...
    (Fedora)