开发者

How do I know if wget actually downloaded a file?

开发者 https://www.devze.com 2023-03-30 05:21 出处:网络
I am writing a shell script that periodically downloads an archive off the internet and processes it.

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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号