[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #31338] find -exec bash -c mv only acts on first thing found by fin
From: |
James Youngman |
Subject: |
[bug #31338] find -exec bash -c mv only acts on first thing found by find |
Date: |
Sat, 16 Oct 2010 09:29:24 +0000 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/533.2 (KHTML, like Gecko) Chrome/5.0.342.7 Safari/533.2 |
Follow-up Comment #3, bug #31338 (project findutils):
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)
_______________________________________________________
Additional Item Attachment:
File name: findtest-consistent-start.sh Size:0 KB
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?31338>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/