Reputation: 63
I am writing a shell script that periodically downloads an archive off the internet and processes it.
I use wget -N $URL so that the file gets downloaded only if a newer version exists. How can I know if a file was actually downloaded so I can avoid unnecessary processing?
Upvotes: 4
Views: 1783
Reputation: 3537
You can try the following
FILE='filename'
CURRENT_TS=`stat -c %y $FILE`
wget -N $URL
NEW_TS=`stat -c %y $FILE`
if [ "$CURRENT_TS" != "$NEW_TS" ]; then
# Do something here.
fi
Upvotes: 6