The error appears because you are moving a folder "
The actual behaviour of
find analyzes first the directory itself, and then its contents.
find, in your example:
1. finds the directory
2. renames it in
prog (so now has a new name)
3. tries to access
4. it gives back an error because now, it is not able to find the folder
find's order of analysing first the directory, and then its contents, is known as "breadth-first traversal". The opposite is "depth-first traversal". There is an option
-depth which invokes this. It is interesting to read mentions of
-depth in the man page for find(1).
-depth: Process each directory's contents before the directory itself."
-delete action also implies
- "Don't forget that the find command line is evaluated as an expression, so putting
-delete first will make find try to delete everything below the starting points you specified."
- "When testing a find command line that you later intend to use with
-delete, you should explicitly specify
-depth in order to avoid later surprises."
-depth, you cannot usefully use