Re: mv to a non-existent path now renames instead of failing
From:
Stephane Chazelas
Subject:
Re: mv to a non-existent path now renames instead of failing
Date:
Thu, 17 Mar 2016 15:45:18 +0000
User-agent:
Mutt/1.5.21 (2010-09-15)
2016-03-17 09:00:37 -0600, Eric Blake:
[...]
> That said, if you WANT an error if 'two/' does not exist, and to move
> 'one' to 'two/one' if 'two/' does exist, you can always use:
>
> mv one two/.
>
> where the trailing '.' changes the semantics required of the rename()
> call, and forces an error if 'two/' does not exist.
[...]
See also the GNU-specific
mv -t two one
To move one into two.
For the reverse: force a move-to as opposed to a move-into,
another GNU-specific option:
mv -T one two
if two is a directory, you'll get an error. If two is a symlink
(to directory or other), one is renamed to two (and the symlink
is gone).
FreeBSD mv has:
mv -h one two
To do a move-to instead of move-into when "two" is a symlink to
a directory.
--
Stephane