Results 1 to 5 of 5
Hello
I've got this line find . -type d -name 'elements' -exec rm -rf {} \; put together to find and delete all directories named elements and their contents.
It ...
- 04-19-2010 #1Linux User
- Join Date
- Jul 2007
- Location
- Greece
- Posts
- 277
find a dir and delete it
Hello
I've got this line find . -type d -name 'elements' -exec rm -rf {} \; put together to find and delete all directories named elements and their contents.
It does work but whenever I run it I get the error/warning
Does anyone know why? It does delete all directories and subdirectories under the name elements though.Code:find: `./dir3/elements': No such file or directory find: `./dir6/elements': No such file or directory find: `./elements': No such file or directory

Thank youOne Love!!!
- 04-19-2010 #2Linux User
- Join Date
- Nov 2009
- Location
- France
- Posts
- 292
Could not figure out why. If it's really annoying, you can redirect to /dev/null or pipe the output of find to rm
0 + 1 = 1 != 2 <> 3 != 4 ...
Until the camel can pass though the eye of the needle.
- 04-19-2010 #3Linux Newbie
- Join Date
- Sep 2004
- Location
- UK
- Posts
- 160
Try
It's probably doing the delete at the higher level, then visiting the child sub/directories. Which are no longer there hence the error messages (just a guess)Code:find . -name "elements" -type d -prune -exec rm -rf {} \;In a world without walls and fences, who needs Windows and Gates?
- 05-06-2010 #4Linux User
- Join Date
- Jul 2007
- Location
- Greece
- Posts
- 277
Thanks guys
One Love!!!
- 05-06-2010 #5


Reply With Quote