I have to write a bash shell script to achieve the following. Get the list of all files from a directory. In the destination directory, if any of these files exist compare the dates. Copy the files to the destination directly only when the source file is newer than the destination file. Has to do this for each file. I have created a for loop to achieve the copy portion. But I need help in comparing the dates of the files.
Thanks
man test
FILE1 -nt FILE2
FILE1 is newer (modification date) than FILE2
FILE1 -ot FILE2
FILE1 is older than FILE2
...
-e FILE
FILE exists
....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With