Created
August 10, 2021 00:04
-
-
Save nacardin/f9c6e2b5c745eb2d5fe030a60e64dfb2 to your computer and use it in GitHub Desktop.
Is dir newer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
src_dir=$(readlink -f $1) | |
dst_dir=$(readlink -f $2) | |
src_timestamp=$(find $src_dir -type f -printf "%T+\n" | sort | tail -1) | |
dst_timestamp=$(find $dst_dir -type f -printf "%T+\n" | sort | tail -1) | |
if [ -z $dst_timestamp ]; then | |
echo "$dst_dir does not exist" | |
elif [[ $src_timestamp > $dst_timestamp ]]; then | |
echo "$src_dir is newer than $dst_dir" | |
else | |
echo "$src_dir is not newer than $dst_dir" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment