[olug] Unix Tip: DEALING WITH TOO MANY FILES

William E. Kempf wekempf at cox.net
Fri Mar 21 20:31:21 UTC 2003


Quinn Coldiron said:
> One of the many problems I have with a certain package I support on AIX
> is that they dump and ton and a half of files into a single directory,
> and I can't change that.  I need to clean that out periodically and rm *
> gives me the same error.  Recursively removing the directory and then
> rebuilding the directory is not an option, so I made a shell script to
> do this:
>
> #!/bin/sh
> for i in `ls -1`
> do
> rm $i
> done
>
> Does somebody know of a better way?

find . -execute rm {} \; # maybe with '-maxdepth 1' to prevent recursion

The find command is one of the most cryptic suckers to master, but oh is
it ever nice once you do.

Just one of many ways to skin this cat.

-- 
William E. Kempf




More information about the OLUG mailing list