[wplug] find + operation

Eric Cooper ecc at cmu.edu
Sat Mar 3 10:58:48 EST 2007


On Fri, Mar 02, 2007 at 11:46:59AM -0500, Zach wrote:
> I would like to be able to do standard file operations like cp, rm and
> mv on the output of: find . -name *.xls -print

There are two main ways to do this.  With find itself, you can use the
-exec action:
    find -name '*.bak' -exec rm -f {} ';'
Here you use {} as a placeholder for the name of the file that has
been found.  The ';' has to be quoted since it's used by find to
indicate the end of the command arguments, and would otherwise be
interpreted by the shell.

Or you can pipe the output of find to the xargs command:
    find -name '*.bak' | xargs rm -f

-- 
Eric Cooper             e c c @ c m u . e d u


More information about the wplug mailing list