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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Saturday 10 March 2007 18:11, Les wrote:
> On Sat, 2007-03-10 at 16:03 +0100, Nigel Henry wrote:
> > On Friday 09 March 2007 01:13, Les wrote:
> > > > 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
> >
> > Thanks Les for that very thorough explanation. I will be more carefull
> > about spaces in the future.
> >
> > A related question, is. How do I find out how many files are in the
> > Sounds-Library directory, including all subdirectories. I looked at ls,
> > but that will only give a list of files, as far as I can see.
> >
> > Thanks.
> >
> > Nigel.
>
> There may be better techniques, but I have used something like:
>  % ls -al | grep -c '\n'
> Which does the recursive list and then counts the lines.  This will
> include the directories I think, but you can try it.  There are also
> varients of the du, df, and ls commands that can provide this sort of
> functionality.

I only got a count of 30 from that, which is way out.
>
>  Try:
>  % man -k file

Looked at that. My there's loads to absorb there, but nothing seemed to match 
what I was looking for. I also tried man -k dir, without success.
>
>  To see a list of commands that work on files.  Some of the Admin
> specific folks can offer help on this as well.

I posted also to the KDE list after your reply to see if there was an option 
for Konqueror to show total files in a directory, and also asked about a CLI 
solution.

Kevin Krammer gave me this CLI one which works.

$ find /path/to/folder -type f | wc -l

My 8.4GB of used space in Sounds-Library is taken up by 17480 .wav files. As I 
said to Kevin, it's little wonder I have problems finding the right sound to 
use.

Nigel.


>
> Regards,
> Les H.


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux