1827295 Members
3959 Online
109717 Solutions
New Discussion

Re: mv question

 
SOLVED
Go to solution
Allanm
Super Advisor

mv question


I have an uninstall script for which I need to move a previous directory ( saved by time stamp ) and need to overwrite it with current directory. So I wrote this command :

mv bin.082307 bin

but it moves the bin.082307 into the current bin directory :

cd bin
ls -lrt
bin.082307

which is what I don't want . I need to overwrite the contents of bin directory with the contents of bin.082307.

Please help.
5 REPLIES 5
Patrick Wallek
Honored Contributor
Solution

Re: mv question

Do this:

cd bin.082307
mv * /bin
A. Clay Stephenson
Acclaimed Contributor

Re: mv question

Read the man page for mv; it's behaving exactly as documented.

If you first rm -r bin and then mv bin.082307 bin, you will get your desired result.
If it ain't broke, I can fix that.
Aussan
Respected Contributor

Re: mv question

mv bin.082307/* bin
The tongue weighs practically nothing, but so few people can hold it
Dennis Handly
Acclaimed Contributor

Re: mv question

Clay had the right idea but I would use rm -rf
or you could just rename bin/.

>Patrick: cd bin.082307; mv * /bin

(You forgot "../bin".)
This will merge directories, not overwrite.

>Aussan: mv bin.082307/* bin

Same problem as Patrick. Also, if files are readonly you would need to add -f.

But this "merges" not replaces the whole directory.
Allanm
Super Advisor

Re: mv question


I used Patrick/Dennis solution.

Thanks,