The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
Delete all injected code recursively ISOcrates Shell Programming and Scripting 2 03-24-2009 11:14 AM
recursively delete the text between 2 strings from a file santosh1234 Shell Programming and Scripting 2 12-29-2008 11:01 PM
delete files recursively in the specified directory deepthi.s Shell Programming and Scripting 3 08-13-2008 10:03 PM
delete files older than 5 minutes in directory (recursively) scarfake Shell Programming and Scripting 3 06-13-2008 01:10 AM
List Files Recursively roberthawke UNIX for Dummies Questions & Answers 9 06-24-2002 06:19 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-29-2009
..Chris.. ..Chris.. is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 4
Delete files Recursively *thumbs*.jpg

Greetings,

I need to delete all files that contain the word thumbs. Those files are spread all throughout sub-directories in a file directory tree.

Is there a script or single line command that will find all files with the word thumbs, and simply delete the file?

For example:

Delete files Recursively *thumbs*.jpg

Thank you in advance for your expertise.

Regards,

..Chris..

Last edited by vbe; 06-29-2009 at 09:55 AM.. Reason: rm SPAM URL
  #2 (permalink)  
Old 06-29-2009
BrightImage BrightImage is offline
Registered User
  
 

Join Date: Jun 2009
Location: UK
Posts: 1
change to the top level directory containing the files (using cd <dir>) and run:

find . -name \*thumbs\*.jpg -type f

if this lists all the files you want to delete then run

find . -name \*thumbs\*.jpg -type f -exec rm {} \;
  #3 (permalink)  
Old 06-30-2009
otheus's Avatar
otheus otheus is offline Forum Staff  
Moderator ala Mode
  
 

Join Date: Feb 2007
Location: Innsbruck, Austria
Posts: 1,864
Quote:
I need to delete all files that contain the word thumbs.
You mean you need to delete all files whose filenames contain the word thumbs.

BrightImage is correct, but this code usually works faster:
Code:
find . -type f -name \*thumbs\*.jpg -print | xargs rm -f

Last edited by otheus; 07-01-2009 at 10:47 AM.. Reason: added -print to find, necessary on some finds
  #4 (permalink)  
Old 06-30-2009
..Chris.. ..Chris.. is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 4
Delete files Recursively *thumbs*.jpg

Sorry, for this additional question. You solution worked, and I had an s in the file name when trying your solution, and noticed it later.

Thank you for your reply. I attempted to list the files using the command below, but nothing showed up? There was no listing of files, but when in the directory, simply typing dir (bin/bash) lists the files that I want to delete.

Code:
find . -name \*thumbs\*.jpg -type f

Last edited by ..Chris..; 06-30-2009 at 11:10 PM..
  #5 (permalink)  
Old 07-01-2009
otheus's Avatar
otheus otheus is offline Forum Staff  
Moderator ala Mode
  
 

Join Date: Feb 2007
Location: Innsbruck, Austria
Posts: 1,864
non-GNU versions of find do not output anything unless you specify -print, -printf, or -ls.
Sponsored Links
Reply

Bookmarks

Tags
delete, file, pattern matching files, recursive

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 01:20 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0