I have some code which pulls a URL and saves it to a file via the `-o` option. The next step in the pipe was failing claiming that the file did not exist.
I was able to download the file just fine via the browser although it was 0 length.
It seems that curl will not write to the file specified via -o if the content-length is 0.
I worked around this by adding a simple step before I curl.
/bin/false >
That creates a 0 length file that will then be updated/overwritten by curl if there is some data, otherwise it will stick around for the next step.
The other choice would be to use redirection to the file, which will always create it, but I’m also using `-w “%{http_code},%{time_total}”` for curl to get status and timing data, which goes to STDOUT and shouldn’t end up in my file.
I hope this will save someone some time.