mv command behavior

Steve Searle steve at stevesearle.com
Mon Jul 9 19:04:04 UTC 2007


Around 05:00pm on Monday, July 09, 2007 (UK time), lists at dwsasia.com scrawled:

> Hi, I don't know if I already sent this question or not, my server  
> died before, and I havn't been able to receive the mails for a while.
> 
> I want to move the files from one dir to another, but only if they are  
> newer. So I do:
> 
> mv -u /tmp/dirA/dirB /dirC/dirB
> 
> Meaning moving it from being a subdir of /tmp/dirA to be a subdir of /dirC.
> 
> The first time it works, but the next time it will end up being like this:
> 
> /dirC/dirB/dirB :(

You should have done:

mv -u /tmp/dirA/dirB /dirC

This will put dirB as a sub directory of /dirC.  The only reason it
worked the first time as you expected was because /dirC/dirB didn'e
exist, so it realised that you wanted the directory moveing.  Once it
already exists, it assuems you want to move the direcory into the path
given in the second argument.

I haven't explained this vey well, but I am sure man 'mv will'.

Steve

-- 
 
 Play Champions - my free football predictions game at:
 	http://www.stevesearle.com/champs/about.html

 20:00:23 up 13 days, 23:39,  1 user,  load average: 0.13, 0.10, 0.10
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/fedora-list/attachments/20070709/dc8e399c/attachment-0001.sig>


More information about the fedora-list mailing list