In
find
argument order matters, a lot.
Arguments can be options, tests and actions. You should typically use options first, then tests, then actions.
Sometimes
find
even warns you about a possible bad ordering (for example when you use -maxdepth
after other arguments), but others it seems it doesn't.
What
find . -delete -name '*ar'
does is:- Finds files and directories upon current directory.
- Deletes them ALL as they are found!
- Then sees if they are named like '*ar' (this part has no effect now).
What you probably want to do is:
find -name '*ar' -delete
This will, for every file, see if it matches
'*ar'
, and only if it satisfies the condition it will delete the file.
Sorry if you found out too late.
沒有留言:
張貼留言