curl / Mailing Lists / curl-users / Single Mail


Re: Exit code if file is or is not downloaded

From: Daniel Stenberg <>
Date: Mon, 15 Apr 2019 22:24:57 +0200 (CEST)

On Mon, 15 Apr 2019, Gerard Seibert wrote:

> I am using curl as shown here: curl -s -L -R -z "file-name" -O "URL"
> What I would like to know is if there is a way to have curl issue an exit
> code depending on whether or not it actually downloaded a newer file.
> Apparently, curl always exits on "0" unless an error occurs which means I
> have to check to see if a newer file was fetched.

You could use -w and output the HTTP response code, as that will be 2xx when
it downloads the file and 304 when not.

Received on 2019-04-15