help-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: question about the "copy, then remove" behaviour of mv


From: Bob Proulx
Subject: Re: question about the "copy, then remove" behaviour of mv
Date: Sun, 25 Oct 2009 13:41:52 -0600
User-agent: Mutt/1.5.18 (2008-05-17)

Musaul Karim wrote:
> When you are moving files with mv, the the mv command appears to copy
> all the files, then delete the ones at the source.

What version of GNU mv are you using?

  mv --version

I do not see that behavior using mv 6.10 for example.  I see mv
calling the kernel's system call rename(2) for each file.  That will
move the file immediately.

Or for cross device movements the rename(2) will fail in which case mv
will copy the file before unlinking the source file.  But in both
cases it is one by one and not batched up all at once later.

This behavior might be different in different versions of the command.

> Is there a way around it to make mv do the "copy, remove" operation
> iteratively per file, rather than as a single operation for all the
> files?

As far as I can tell this is the default behavior.  You can see what
is happening with your mv command by using the strace command to
trace the system calls.  For example:

  strace -o /tmp/mv.strace mv dir1/somefiles* dir2/

Bob




reply via email to

[Prev in Thread] Current Thread [Next in Thread]