views:

919

answers:

4

Hi. 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 ? (Centos 5) thanks.

+10  A: 

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.

alamar
I made a written mistake.mv -if old/* new/ not work
Qooe
'Not work' is useless. What does it say? What happens when you try?
alamar
A: 
prompt$ man mv
Boris Guéry
+2  A: 
reef@localhost:/tmp/experiment$ ls a
11  22  33
reef@localhost:/tmp/experiment$ ls b
22  33
reef@localhost:/tmp/experiment$ ls
a  b
reef@localhost:/tmp/experiment$ mv a/* b
reef@localhost:/tmp/experiment$ ls a
reef@localhost:/tmp/experiment$ ls b
11  22  33

It works. What are You trying to achieve? Could You please write a short example of what the input data should look like and what the output data should look like? The truth is I have no idea what You are trying to do :) Help me help You.

Reef
A: 

If you are copying from an ext2/3/4 file system to a FAT32 file system, and a filename has an invalid character for FAT32 naming conventions, you get this terribly annoying and incorrect as hell error message. How do I know? I wrestled with this bug - yes, it's a KERNEL BUG - for 6 hours before it dawned on me. I thought it was a shell interpreter error, I thought it was an "mv" error - I tried multiple different shells, everything. Try this experiment: on an ext file system, "touch 'a:b'" them "mv" it to a FAT32 file system. Try it, you'll enjoy (hate) the results. The same is true for '<' and '>' (\074 and \076).

Thanks for "man mv" - that's a real big help, don't quit your day job.

Henry Killinger