-   Programming (
-   -   Pipe output of find through rm? (

CelticBlues 07-28-2008 07:52 PM

Pipe output of find through rm?
I am trying to locate some rogue files on my machine (I know the name or some form of it since I put them on the machine...) I know I can find them by using find


find / -name "libBooger*"
which should return the pathname of every file that begins with libBooger, right?

I also know that I can pipe output from a command through grep. For example if I do this


find / -name "libBooger*" | grep Brain
Then the output would be all files starting with libBooger and containing Brain somewhere in the pathname, right?

Ok, so what I want to do is use find to locate all of these rogue files, and then delete them as they are found... Can I pipe the output of find through rm? If so, how.... I know this


find / -name "libBooger*" | rm
Doesn't work...


(I don't fail... I succeed at finding all the ways that do not work)

ghostdog74 07-28-2008 08:06 PM


find / -name "libBooger*" -delete

billymayday 07-28-2008 08:15 PM

Or, for the exercise,


find / -name "libBooger*" -exec rm -f {} \;

Hko 07-29-2008 03:09 AM

Or, for another exercise:

find / -name "libBooger*" -print0 | xargs -0 rm

All times are GMT -5. The time now is 08:17 AM.