4 ms·
curl -O https://curl.se/docs/manpage.html#-O https://curl.se/docs/manpage.html#-O
by dwb 3y ago
curl -O
https://curl.se/docs/manpage.html#-O https://curl.se/docs/manpage.html#-O
- OskarS 3y agoI much prefer the fact that curl doesn't do this by default (but has the option), it much closer matches the behavior of most unix-y tools. Makes it so much easier to put it into pipelines.
- throw0101a 3y agoWhat's "better" depends on whether you 'just' want to download a file, or if you want to build an larger workflow. For me, I usually want to download files and I'm usually not doing any more processing, so I tend to type in *wget" first.
- TheFuzzball 3y agoI usually use `curl -OL <url>` or `curl -L -o <local-filename> <url> instead of wget. wget is better for download lists, but I'd accept the argument that a simple shell script is similarly easy.
- mananaysiempre 3y agoAlso -OJ : with -O you get the name derived from the URL (the initial one, I think, even if redirects are being followed), with -OJ you get the one from the Content-Disposition header or the final URL, the way browsers do it. Of course, plain -O is safer. (For parity with Wget, you might also want to add -R to set the downloaded file’s mtime according to the Last-Modified header.)
- darnir 3y agoWget will give you an equivalent with the --content-dispisition flag. I would like for it to be the default, but it would likely break backwards compatibility with some scripts that except a different output filename.
- madfucker69 3y ago-OJ is nice but doesn't work with -C- for some reason
- mananaysiempre 3y agoTrue. AFAIU the reason is that Curl wants to make a single request (modulo redirects), whereas making -OJC- work would require two: issue a HEAD to receive the Content-Disposition header and learn the file name, then look at that file and see how long it is, then issue a GET with a Range header to request the suffix you still need to download. With other methods I don’t think you could make this work at all. I don’t know if Stenberg is opposed to a GET-specific solution, perhaps that could be a fun project. (Although I’ve encountered noncompilant servers that couldn’t handle HEADs.)
- throw0101a 3y ago> curl -O Yes. But the GP said by default.
- dwb 3y agoI was obviously responding to the curl command they posted. I didn't say anything about default behaviour.
- malablaster 3y agoNo, OP said… > you would have to do `curl url://to/file.htm > file.htm` or some other, less ergonomical, incantation … which begs the conclusion that OP is unaware of `-O`.
- enriquto 3y agoI'm well aware of curl's -O (long form: --remote-name), but it has an unfortunate clash with an option of the same name from wget (long form: --output-document). These options have closely related yet very different meanings. Using these options without looking at the manpage fills me with a sense of dread that I prefer to avoid.
- photochemsyn 3y agoman curl | grep -C 2 " -O" --remote-name-all This option changes the default action for all given URLs to be dealt with as if -O, were used for each one. So if you want to disable that for a specific URL after --remote-name-all has been used, you must use "-o -" or --no-remote-name. alias curl='curl --remote-name-all'