<div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">
>> can anyone show me a bash test to put before mv that will tell whether<br>
>> mv will do a simple rename or a copy and delete? for example for mv<br>
>> into a --bind mount, df reports both locations as within the same fs,<br>
>> yet mv will copy and delete. the best test I can think of would create<br>
>> a file, mv and see what happens. can anyone concoct an accurate test<br>
>> that doesn't need to create a test file? (or perhaps reveal an mv<br>
>> alternative..)<br>
<br>
</div>Suppose you are moving FILENAME to DIR. I think you want to do both:<br>
<br>
stat -c %d FILENAME<br>
stat -c %d DIR/<br>
<br>
Note the slash at the end of DIR/. If DIR is a symlink to a mounted<br>
device then these will give different answers and you only want the second<br>
of the two answers:<br>
<br>
stat -c %d DIR<br>
stat -c %d DIR/<br>
...<br>
So I think this is the kind of thing you want to do:<br>
<br>
FILENAME="$1"<br>
DIRNAME="$2"<br>
<br>
if [ $(stat -c %d "$FILENAME") == $(stat -c %d "${DIRNAME}/") ] ; then<br>
echo RENAME<br>
else<br>
echo COPY/DELETE<br>
fi<br></blockquote><div><br>thanks.. but for me they all show the same device whether inside or outside a
--bind, unfortunately that doesn't provide a clue that mv across the mount boundary will copy&delete instead of rename..<br>
</div></div>