The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Searching in VI andyblaylock UNIX for Dummies Questions & Answers 1 11-28-2007 05:32 PM
searching for $ character MizzGail UNIX for Dummies Questions & Answers 4 01-05-2006 08:21 PM
Searching a directoy gumsun UNIX for Dummies Questions & Answers 3 01-05-2006 03:18 PM
searching searching tony3101 Shell Programming and Scripting 3 06-04-2004 08:50 AM
searching for { yotoruja Shell Programming and Scripting 4 11-03-2003 07:07 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 08-07-2007
Registered User
 

Join Date: Aug 2007
Posts: 5
Searching and deleting

Hi Guys
I hope this is an easy one, is it possible to write a unix bash script, (or just a command) to search for wildcards and then delete that wildcard once it is found, and the search is performed over a whole directory tree. eg it searches for *.ppp then once it finds them it deletes ???.ppp. Sorry I'm a not too clued up on unix yet so any help would be great

thanks heaps
Reply With Quote
Forum Sponsor
  #2  
Old 08-08-2007
robotronic's Avatar
Can I play with madness?
 

Join Date: Apr 2002
Location: Italy
Posts: 370
Enter in the "root" of your directory tree and then:

Code:
find . -name "*.txt" -exec ls -l {} \;
Once you are sure that the displayed files are the ones you which to remove, change the "ls" command with "rm":

Code:
find . -name "*.txt" -exec rm {} \;
For more info try also "man find" and search for the "-exec" option.
Reply With Quote
  #3  
Old 08-08-2007
Registered User
 

Join Date: Aug 2007
Posts: 5
Thankyou so very much, that was exactly what I wanted
Reply With Quote
  #4  
Old 08-08-2007
Registered User
 

Join Date: Aug 2007
Posts: 5
Sorry last question

Is it possible to perform that above command but exclude a directory - say I did a search with in their home area but wanted to exclude the library directory how would I do that?

Thanks heaps
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:18 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0