[TriLUG] bash help
ed at eh3.com
Thu Oct 28 12:02:52 EDT 2004
On Thu, 2004-10-28 at 11:40, Jeremy Portzer wrote:
> Some good suggestions here. I agree that writing this in Perl or Python
> etc. would probably give you the best flexibility, but regardless, you
> should look into the "find" program to find the old files that you wish
> to delete. Find has a myriad of options for selecting, sorting, etc,
> that should do what you need. Tip: use the -print0 flag to output the
> files separated by NULL characters, and then pipe that to "xargs -0" to
> do the actual deletion. Using xargs is much faster than the "-exec"
> stuff within find itself, and using the NULL field will eliminate
> problems with filenames with spaces.
Yes, this is excellent advice!
> Also keep in mind that "du" takes quite a while to run as it goes
> through the whole directory structure. If the files are on their own
> parition, you can simply use "df" instead, which returns instantly.
Very true. And if you have one or more users who create tremendous
numbers of files (particularly in one directory), then the 'du', 'ls',
and even 'find' commands can take forever (no matter which language you
use to access the functionality). In these cases, its a good idea to
look into quotas since the quota system amortizes the cost of
determining the per-user disk usage.
Edward H. Hill III, PhD
office: MIT Dept. of EAPS; Rm 54-1424; 77 Massachusetts Ave.
Cambridge, MA 02139-4307
emails: eh3 at mit.edu ed at eh3.com
URLs: http://web.mit.edu/eh3/ http://eh3.com/
More information about the TriLUG