Sat 16 Oct 2010 09:29:24 AM UTC, comment #3:
I'm leaving just the shell commands, to avoid markup issues.
echo "With echo find outputs for all three a.file, b.file, and c.file"
'echo cp "$1" ~/test/find/2/ && echo mv "${1%/*}" ~/test/find/3/'
Clearly the above command does not modify the filesystem.
echo "But when echo is removed, find only works on the first."
'set -x; cp "$1" ~/test/find/2/ && mv "${1%/*}" ~/test/find/3/'
This one modifies the filesystem while find is examining it:
+ cp /home/james/test/find/1/c/c.file /home/james/test/find/2/
+ mv /home/james/test/find/1/c /home/james/test/find/3/
/home/james/test/find/1/c is being moved somewhere else while (probably) find is inside it. Since this time you are modifying the filesystem, while in the previous example you are not, I don't understand why you expect the output of find to be the same.
echo "Changing mv to cp -r then does more than one"
'set -x; cp "$1" ~/test/find/2/ && cp -r "${1%/*}" ~/test/find/3/'
Here you are adding new entries but nor removing or moving any, so it is not surprising that the output is longer. But the initial conditions here are not the same as in your first example, because the second example has moved things around. Fixing that produces a full set of output just like the first example.
I attach an example script with the change I mention.
(file #21691)
|