How do I preserve the remote filename when Downloading a file using curl [duplicate] How do I preserve the remote filename when Downloading a file using curl [duplicate] curl curl

How do I preserve the remote filename when Downloading a file using curl [duplicate]


The solution is to use -O -J

-O, --remote-name          Write output to a file named as the remote file  -J, --remote-header-name   Use the header-provided filename

So...

curl  -O -J  'http://oregondigital.org/cgi-bin/showfile.exe?CISOROOT=/baseball&CISOPTR=0'

I had to upgrade my CURL. I had v 7.19 which doesn't support -J but 7.22 (which is the latest) does.


You can use the -o option can you? eg

 curl  'http://oregondigital.org/cgi-bin/showfile.exe?CISOROOT=/baseball&CISOPTR=[0-9]' -o "#1.jpg"