LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 07-28-2008, 07:52 PM   #1
CelticBlues
LQ Newbie
 
Registered: Jan 2005
Posts: 29

Rep: Reputation: 15
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)
 
Old 07-28-2008, 08:06 PM   #2
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,695
Blog Entries: 5

Rep: Reputation: 241Reputation: 241Reputation: 241
Code:
 find / -name "libBooger*" -delete
 
Old 07-28-2008, 08:15 PM   #3
billymayday
Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Or, for the exercise,

Code:
find / -name "libBooger*" -exec rm -f {} \;
 
Old 07-29-2008, 03:09 AM   #4
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 108Reputation: 108
Or, for another exercise:
Code:
find / -name "libBooger*" -print0 | xargs -0 rm
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Redirecting sh output to a pipe elmafiacs Programming 0 05-10-2006 01:55 PM
pipe find output to scp groundhog_killer Linux - Networking 2 02-14-2006 10:46 AM
how to pipe output from make BBB Programming 2 05-20-2005 06:14 AM
Read the output from a pipe with bash ? fluppi Linux - Software 3 01-13-2004 12:59 PM
Output truncated when using pipe tells Linux - General 1 12-16-2003 08:06 PM


All times are GMT -5. The time now is 07:44 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration