3

I am using curl with both -C - and --remote-name --remote-header-name. If the file exists, I get an error that the existing file cannot be overwritten.

Is there a way to work around this? I think this is not an uncommon use case?

// Edit: I want to resume downloading the file.

1 Answers1

2

curl may support skipping files when used with both -O and -J, but its behavior is inconsistent.

The -J (--remote-header-name) option basically tells the -O (--remote-name) option to use the server-specified Content-Disposition filename instead of extracting a filename from the URL. Curl then doesn't know what file name the server will return and it may ignore the existing file as a safety precaution.

However, the behavior is unpredictable and it doesn't work for all files.

You may find more information and possible workarounds in the post
How to skip already existing files when downloading with curl?

harrymc
  • 480,290