Move files from one directory into another without affecting the existing directory using mac terminal

June 18, 2009    command mv mac terminal

As part of using mac terminal more and more in my own day to day work, I today needed to be able to move all the files and folder from a directory back one directory in the main http folder on my server.

I needed to move all of the files from a file that I unzipped straight to the server, which unfortunately also created another subfolder called PhpEx in my http directory.

So I want to copy of the files and folders from /sites/dunelink.com/http/PhpEx back a directory to /sites/dunelink.com/http

This is how I did it:

mv /sites/dunelink.com/http/PhpEx/* /sites/dunelink.com/http

Notice the * this denotes move everything within the folder but not the actual folder. This will also leave the existing folder untouched exactly where it already is.

If you wish you can then delete the PhpEx folder and all its files with one simple command.

rm -rf /sites/dunelink.com/http/PhpEx

Hope this helps


blog comments powered by Disqus