I've unpackaged a zip into the current location which we'll call /httpdocs, everything inside the zip resides in a directory which we'll call myfiles.
In /httpdocs are thousands of directories and files that also exist at exactly the same paths as in the myfiles directory.
I need to move the contents of the myfiles directory into /httpdocs whilst replacing any directories/files that already exist... recursively.
If I try from the myfiles directory:
mv * ../
I am asked if I want to overwrite if exists... y/n for every single file!
If I try from /httpdocs:
mv myfiles/* .
I am asked if I want to overwrite if exists... y/n for every single file!
If I try to apply the -f force operator, it returns that it cannot move because the Directory not empty.
Now from what I have read, it doesn't seem like what I am trying to do is achievable with the mv command which is probably why I am seem to be getting absolutely nowhere with this.
I am aware of cp and rsync and many others but I am not sure which command is the best to use to actually just move the contents of the directory to another location and overwrite if exists recursively.
I know I could do this easily by just uploading to /httpdocs via FTP in any local client and just 'Yes to all' on the overwrite dialogue but it would just take ages so not always practical - I'm just after a like-for-like over the command line really.
cplikecp -r * ..from mymyfilesdirectory yet when I try that, I am asked y/n to overwrite for every file still. This is what I mean by I can't find something online that actually does what I am seeking. – zigojacko Nov 15 '18 at 10:55cpshould overwrite existing files by default. Can you check if you have an alias configured for cp in your environment? It may be mapped tocp -ior so. – Haxiel Nov 15 '18 at 10:58which cpreturnsalias cp='cp -i' /bin/cp- no wonder this has been doing my head in all of this time. Will try and remove the alias and try again. Thanks. – zigojacko Nov 15 '18 at 11:03unalias cpand thecpcommand worked perfectly as it should do. Thank you @Haxiel for directing me to the problem (never knew about command aliases) - I do believe my question/scenario is different to that of the suggested duplicate question though and I will accept an answer if you wanted to add it. – zigojacko Nov 15 '18 at 11:14