How do I know if wget actually downloaded a file?
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 versi开发者_StackOverflow社区on exists. How can I know if a file was actually downloaded so I can avoid unnecessary processing?
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
精彩评论