in reply to Re^2: Renaming Direcotries
in thread Renaming Directories

Careful. That will not work across filesystems.
And in that case, neither would system "mv"....

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: •Re: Re^2: Renaming Direcotries
by davis (Vicar) on Jun 27, 2002 at 08:37 UTC
    And in that case, neither would system "mv"....
    Hmmm, my docs (v5.6.1) disagree. From perldoc -f rename
    Behavior of this function varies wildly depending on your system implementation. For example, it will usually not work across file system boundaries, even though the system mv command sometimes compensates for this.

    davis
    Is this going out live?
    No, Homer, very few cartoons are broadcast live - it's a terrible strain on the animator's wrist
      The docs are fuzzy, and probably deserve patching.

      The mv command has issued a cp behind the scenes to rename a file from one volume to another for at least 20-ish years of Unix history.

      However, I have yet to see an mv command that would transparently handle the moving of a directory from one filesystem to another. Are you aware of even one?

      -- Randal L. Schwartz, Perl hacker

        However, I have yet to see an mv command that would transparently handle the moving of a directory from one filesystem to another. Are you aware of even one?
        I'm aware of three examples:
        • Mandrake Linux 8.2
          Edited output from mount:
          /dev/scsi/host0/bus0/target0/lun0/part9 on /tmp type reiserfs (rw)
          /dev/scsi/host0/bus0/target1/lun0/part2 on /home type reiserfs (rw)
          # mkdir /home/test
          # touch /home/test/testing
          # ls -la /tmp/test
          ls: /tmp/test: No such file or directory
          # mv /home/test /tmp
          # ls -la /tmp/test
          total 8
          drwxr-xr-x 2 root root 72 Jun 28 09:26 ./
          drwxrwxrwt 106 root root 6736 Jun 28 09:26 ../
          -rw-r--r-- 1 root root 0 Jun 28 09:26 testing
        • HP-UX 11.00
          Edited output from mount:
          /tmp on /dev/vg00/lvol4 delaylog,nodatainlog on Fri May 10 15:37:38 2002
          /home on /dev/vg00/lvol5 delaylog,nodatainlog on Fri May 10 15:37:38 2002
          # mkdir /home/test
          # touch /home/test/testing
          # ls -la /tmp/test
          /tmp/test not found
          # mv /home/test /tmp
          # ls -la /tmp/test
          total 10
          drwxr-xr-x 2 root sys 96 Jun 28 09:40 .
          drwxrwxrwx 9 bin bin 5120 Jun 28 09:41 ..
          -rw-r--r-- 1 root sys 0 Jun 28 09:40 testing

        I've tried it on a FreeBSD 4.5 box, and that also worked.
        Cheers.
        davis
        Is this going out live?
        No, Homer, very few cartoons are broadcast live - it's a terrible strain on the animator's wrist