Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
Is project really in the / directory or is the leading slash a typo? – Dennis May 22 '13 at 17:53
up vote 2 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

you may try following

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

share|improve this answer
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .