Delete files Recursively *thumbs*.jpg


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Delete files Recursively *thumbs*.jpg
# 1  
Old 06-29-2009
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 11:55 AM.. Reason: rm SPAM URL
# 2  
Old 06-29-2009
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  
Old 06-30-2009
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 12:47 PM.. Reason: added -print to find, necessary on some finds
# 4  
Old 07-01-2009
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..; 07-01-2009 at 01:10 AM..
# 5  
Old 07-01-2009
non-GNU versions of find do not output anything unless you specify -print, -printf, or -ls.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Delete empty directories recursively - HP-UX

Hi, I want to delete all empty directories in a long directore tree structure. I want to use that from a script that will run on HP-UX 11. My definition of empty directory is that there is no regular file under it and directly beneath it. To elaborate, I have below directories. /app/dev/java... (14 Replies)
Discussion started by: asutoshch
14 Replies

2. Shell Programming and Scripting

Decompress (with gunzip) recursively, but do not delete original gz file

Hi all, I have a folder hierarchy with many gz files in them. I would like to recursively decompress them, but keep the original files. I would also like to move all the decompressed files (these are very large HDF5 files with .CP12 extension) to another data folder. Currently I am using four... (3 Replies)
Discussion started by: gansvv
3 Replies

3. UNIX for Dummies Questions & Answers

Deleting all but JPG files

I would like to delete all files but keep all the .JPG files. How can this be accomplished? Thanks in advance (8 Replies)
Discussion started by: Xterra
8 Replies

4. UNIX for Advanced & Expert Users

Recursively delete only specified directories with given pattern

Hi All, We have a requirement to recursively delete the directories and its subdirectories older than 60 days based on timestamp (folder creation timestamp)under certain directory. However it has some specific requirements. The directories will continue to be there upto any depth. the... (0 Replies)
Discussion started by: rcvasu
0 Replies

5. Shell Programming and Scripting

Rename all ".JPG" files to ".jpg" under all subfolders...

Hi, Dear all: One question ! ^_^ I'm using bash under Ubuntu 9.10. My question is not to rename all ".JPG" files to ".jpg" in a single folder, but to rename all ".JPG" files to ".jpg" in all subfolders. To rename all ".JPG" to ".jpg" in a single folder, for x in *.JPG; do mv "$x"... (7 Replies)
Discussion started by: jiapei100
7 Replies

6. UNIX for Dummies Questions & Answers

delete recursively contents of folders

hi, I've a folder structure like : /home/project/LIBNAMEA/FILE1 /home/project/LIBNAMED/FILE2 /home/project/LIBNAMEC/FILE3 /home/project/LIBNAMED/FILE4 /home/project/LIBNAMEX/FILE5 (there is no relation in the letters after the project/ ) and i need to delete the files keeping... (5 Replies)
Discussion started by: jtmartins
5 Replies

7. Shell Programming and Scripting

Delete all injected code recursively

Recently all of the php files on my server got injected with some dating site code and I'm trying to get rid of it all at once. I've tried using sed but I don't know how to escape it correctly because I don't really know what I'm doing. Could you guys help me with the syntax? find ./* -type f... (2 Replies)
Discussion started by: ISOcrates
2 Replies

8. Shell Programming and Scripting

recursively delete the text between 2 strings from a file

i have 200000bytes size of a unix file i need to delete some text between two strings recursively using a loop with sed or awk . these two strings are : 1st string getting from a file :::2 nd string is fi...its constant . can anyone help me sed -n'/<1 st string >/,/fi/' <input_filename> is the... (2 Replies)
Discussion started by: santosh1234
2 Replies

9. Shell Programming and Scripting

delete files recursively in the specified directory

I have to write a shell script which can delete all the files and directories recursively inside the specified directory but should not delete the specified directory. Please some body help me in writing the script. (3 Replies)
Discussion started by: deepthi.s
3 Replies

10. Shell Programming and Scripting

delete files older than 5 minutes in directory (recursively)

sorry guys can some please give me a hint how to achieve this in a slick oneliner? delete files older than 5 minutes in specified directory (recursively) peace (3 Replies)
Discussion started by: scarfake
3 Replies
Login or Register to Ask a Question