in reply to Re: Moving Files
in thread Moving Files

The advantage is that on (modern) systems, mv works if the target location is on a different device than the original file. rename fails.

Replies are listed 'Best First'.
Re^3: Moving Files
by kyle (Abbot) on Aug 07, 2008 at 17:06 UTC
      Hmmm, let's not, shall we? At least, not if you care about your permission bits.
      $ touch /tmp/foo $ chmod -w+x /tmp/foo $ ls -l /tmp/foo $ -r-x------ 1 javafan staff 0 Aug 7 18:16 /tmp/foo $ perl -MFile::Copy -wE 'move "/tmp/foo", "/var/tmp/foo"' $ ls -l /var/tmp/foo $ -rw------- 1 javafan staff 0 Aug 7 18:16 /var/tmp/foo
      But with mv:
      $ touch /tmp/foo $ chmod -w+x /tmp/foo $ ls -l /tmp/foo $ -r-x------ 1 javafan staff 0 Aug 7 18:18 /tmp/foo $ mv /tmp/foo /var/tmp/foo $ ls -l /var/tmp/foo $ -r-x------ 1 javafan staff 0 Aug 7 18:18 /var/tmp/foo