[olug] Unix Tip: DEALING WITH TOO MANY FILES

Christopher Cashell topher at zyp.org
Sat Mar 22 08:17:57 UTC 2003


At Fri, 21 Mar 03, Unidentified Flying Banana 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:

Have you tried using xargs?  (Assuming it's available on AIX.)

[Snip: Shell script.]

> Does somebody know of a better way?

Wouldn't 'ls | xargs rm' work?

The Unix tip didn't really explain what xargs does, it just showed an
example of it.  The syntax of it is 'xargs [command]'.  What it does, is
take a command, read from standard input, and for each item that
comes in on standard input, it executes the given command.

So, the above would run 'ls', and for each ITEM that ls sends to
standard output, xargs would run 'rm ITEM'.

Unless I'm missing something about what you're trying to do, I think
this'll work for you.

> Quinn

-- 
| Christopher
+------------------------------------------------+
| A: No.                                         |
| Q: Should I include quotations after my reply? |
+------------------------------------------------+



More information about the OLUG mailing list