Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to remove files that are located in different folders.

I have

find /project/test/ -name "*junk-12.png" -delete

to delete anything like

`project/test/bad/testjunk-12.png` and `project/test/good/gojunk-12.png`

However, the files are still there after I ran the command.

I was hoping if anyone here can help me out on this one. Thanks a lot!

share|improve this question
    
Does it print the files if you leave out the delete option? –  slhck May 22 '13 at 17:18
4  
Is project really in the / directory or is the leading slash a typo? –  Dennis May 22 '13 at 17:53
add comment

2 Answers 2

up vote 1 down vote accepted

Normally the following should work:

find ./project/test -name "*junk-12.png" -type f -exec rm {} \;

Your command should work too, if you replace /project/test by ./project/test.

share|improve this answer
add comment

you may try following

rm -f `find /project/test/ -name "*junk-12.png"`

share|improve this answer
5  
This will horribly fail if any of the paths found contains a space. A safer alternative would be to remove the files and folders found through the exec option of find. Please note that you have to escape back ticks or indent code by 4 spaces. –  slhck May 22 '13 at 17:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.