How do I save a file using the response header filename with cURL?

curl http://example.com/dl.php?file=3123123 -O -J

if server uses redirection use these:

--location-trusted
--max-redirs 10

-J/--remote-header-name is the option you want.

You use -J in conjunction with -O, which makes curl use the file name part from the URL as its primary way to name the output file and then if there is a Content-disposition: header in the response, curl will use that name instead.

Tags:

Curl