Overnout
Overnout

Reputation: 63

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 version exists. How can I know if a file was actually downloaded so I can avoid unnecessary processing?

Upvotes: 4

Views: 1783

Answers (1)

Doug Kress
Doug Kress

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

Related Questions