> > >> can anyone show me a bash test to put before mv that will tell whether > >> mv will do a simple rename or a copy and delete? for example for mv > >> into a --bind mount, df reports both locations as within the same fs, > >> yet mv will copy and delete. the best test I can think of would create > >> a file, mv and see what happens. can anyone concoct an accurate test > >> that doesn't need to create a test file? (or perhaps reveal an mv > >> alternative..) > > Suppose you are moving FILENAME to DIR. I think you want to do both: > > stat -c %d FILENAME > stat -c %d DIR/ > > Note the slash at the end of DIR/. If DIR is a symlink to a mounted > device then these will give different answers and you only want the second > of the two answers: > > stat -c %d DIR > stat -c %d DIR/ > ... > So I think this is the kind of thing you want to do: > > FILENAME="$1" > DIRNAME="$2" > > if [ $(stat -c %d "$FILENAME") == $(stat -c %d "${DIRNAME}/") ] ; then > echo RENAME > else > echo COPY/DELETE > fi > 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.. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.mn-linux.org/pipermail/tclug-list/attachments/20101202/d428b950/attachment.htm