I have 2 directories dir1 and dir2 which contains many xml files. I need to compare files of dir1 with that of dir2 and if they match, I need to cut it from dir1 and paste it in dir2. I need to do this thru scripts. I'm currently investigating on the diff command. Please help me write the script.
The folders will not necessarily end up the same. I just want to take each file in dir1, check if it exists in dir2, if it exists, overwrite it by the file in dir1 and then remove it from dir1. If it does not exist, just don't do anything.
I need to do this in view of correcting the 2 folder contents because some program error has caused the folders to be in an incorrect state.