On 2018-06-01 04:08, Grady Martin wrote:
Hello. I have two questions:
· Is there a way to recursively merge two directories with move (not
copy/delete) operations, using standard GNU utilities?
· If not, how do coreutils' maintainers feel about an
-r/-R/--recursive patch for mv?
We can almost do this already, with cp, except that the files also
remain a the source.
■ mv -R old new
■ ls -R
I.e.
cp -rl old/. new/.
The new/ tree is populated with hard links to corresponding objects in
old, which is what mv will do (on the same filesystem, anyway).
Basically, if cp had an option called "--remove-source", which does what
its name says, I think it would do what you want.
cp itself could optimize using hard linking when that option is
specified, and the source and destination directories are on the same
filesystem, which supports linking.
cp with --remove-source would just about obsolesce mv.