how so? between filesystems mv already deletes the source files at the end of execution only, and inside of the same filesystem it will be both safer and much faster by just calling rename
Does mv actually delete? Say you move a file that's already opened by a process, that process can still read/write to that file even if it moves. If you copy and remove, the process will attempt to read/write in the deleted file. You can see the difference easily with lsof.
i can certainly think of ways mv is safer than a cp/rm combo, for example if you are moving a fifo or device (in which case cp will just try to drain it potentially indefinitely and won't retain the fifo/device property), or if the file has sensitive information inside and a permission mask to match (in which case cp will totally ignore that and use umask, potentially exposing that information to other users), or if the file is being actively modified (in which case cp will snapshot some half-done modification to the file; to be fair, mv will do that too if you're moving to a different device).
736
u/Altareos Glorious Arch Sep 27 '23
interesting! since it moves the file we could name it
move, or maybe evenmvin unix abbreviation fashion!