The error appears because you are moving a folder "prog-*
".
The actual behaviour of find
is:
find
analyzes first the directory itself, and then its contents.
So, find
, in your example:
1. finds the directory prog-3.6.9-stable-gnu
2. renames it in prog
(so now has a new name)
3. tries to access prog-3.6.9-stable-gnu
4. it gives back an error because now, it is not able to find the folder prog-3.6.9-stable-gnu
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."
- "The
-delete
action also implies -depth
."
- "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."
- "Because
-delete
implies -depth
, you cannot usefully use -prune
and -delete
together."