LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Pipe output of find through rm? (http://www.linuxquestions.org/questions/programming-9/pipe-output-of-find-through-rm-658883/)

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

Code:

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

Code:

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


Code:

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

CB

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

ghostdog74 07-28-2008 08:06 PM

Code:

find / -name "libBooger*" -delete

billymayday 07-28-2008 08:15 PM

Or, for the exercise,

Code:

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

Hko 07-29-2008 03:09 AM

Or, for another exercise:
Code:

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


All times are GMT -5. The time now is 02:06 PM.