LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-13-2005, 05:46 AM   #1
stefaandk
Member
 
Registered: Jun 2005
Distribution: Centos
Posts: 215

Rep: Reputation: 30
Remove files based on content


I'm trying to remove all files if they have a certain content

find /var/qmail/queue/mess/ -exec grep yahoo {} \; -print

The above find command manages to list me the files but now I want to combine that command with actually deleting those files.

But I can't seem to get the syntax right

Ta
 
Old 08-13-2005, 06:23 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

Something like this should work:

find /var/qmail/queue/mess -exec grep -l "yahoo" {} \; -exec rm {} \;

Hope this helps.
 
Old 08-13-2005, 09:03 AM   #3
stefaandk
Member
 
Registered: Jun 2005
Distribution: Centos
Posts: 215

Original Poster
Rep: Reputation: 30
Ripper Druuna, that did the trick beautifully!

Good on ya!
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script to remove old files based on date WindozBytes Linux - General 12 06-04-2012 02:21 AM
How to find files with the necessary content? kornerr Linux - General 6 08-09-2005 06:48 AM
renaming text files based upon a pattern in their content Spacepup Linux - General 1 07-28-2005 02:43 PM
Finding files based on content benjaminrtz Linux - General 2 08-05-2002 12:01 AM
Can iptables be configured to reject web requests based on content? steppin_razor Linux - Security 10 11-29-2001 01:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:37 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration