Linux command to move a directory

Qooe picture Qooe · May 15, 2009 · Viewed 56.4k times · Source

My old and new directory have same folders and files inside.

I try:

mv -if old/* new/*

and get error

mv: cannot move `./xxxxxx' to a subdirectory of itself

How can I move it?

Answer

alamar picture alamar · May 15, 2009

You should use mv -if old/* new/ without the trailing *.

This is because it unrolled to

mv -if old/foo old/bar old/baz new/foo new/bar new/baz

i.e. move everything into new/baz

This is not what you wanted.