how would I be able to compare two directories' files and replace their timestamps if the files exist in both directories in bash script? For example, I have file1.txt in Directory1 and file1.txt in Directory2 (the directories are given as arguments) that have different timestamps, and I want to replace the newer timestamp with the older. How would I do that?
I already know that I should be using the touch command (https://askubuntu.com/questions/62492/how-can-i-change-the-date-modified-created-of-a-file) for that end, and also use -nt and -ot (compare file's date bash) for comparing the files, but since I'm fairly new to scripting, I'm having some trouble figuring out how to put all this together.