[Top][All Lists]

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

Re: du enhancement

From: Bob Proulx
Subject: Re: du enhancement
Date: Sun, 24 Jun 2001 09:46:04 -0600

> I'm working on a packaging system that produces statistics of the size of 
> different types of files. It uses fileutils/du for this and passes the files 
> as arguments. There is, however, a limit to how many arguments can be passed 
> to a program, and for packages with a lot of files this is a problem. 
> Therefore I am asking you to consider adding support for reading the file 
> list on stdin. I made my own patch, and it worked, but as I am a newbie to C 
> I trust you to produce better code and thus there is no need to send my patch 
> to you.

Thanks for your suggestion.  But this functionality is already present
in 'find'/'xargs' for use by all unix utilities.  Adding it to each
and every utility goes counter to the unix principles of modularity.
It would cause code bloat and more problems because in practice
different commands would implement it differently.

You did not say exactly what you were attempting.  Let's take an
example and compute the sizes of all .html files.

  find . -name '*.html' -print | xargs du -s

Using GNU findutils you can use the 'zero terminated strings'
extension and handle files that include newlines as well.  This is the
most robust way to do this because it handles any filename.

  find . -name '*.html' -print0 | xargs -0 du -s

Note that 'find' has very powerful include/exclude patterns.  You can
look for files that are larger than 1MB that are not owned by root
created in the last day and other such combinations.  Using -printf
you can get very creative.  Check it out!


reply via email to

[Prev in Thread] Current Thread [Next in Thread]