curl / Mailing Lists / curl-users / Single Mail
Buy commercial curl support. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder Daniel himself.

Re: "--out-null"?

From: Bastian Jesuiter via curl-users <curl-users_at_lists.haxx.se>
Date: Wed, 17 Sep 2025 08:12:10 +0200

Hi,

Curl infers the name from the last path segment. (When you use the -O
option)

Combined with a head request, which will only return the response headers,
but not the file (it's basically a get without response body), you should
be able to print the url-effective or urle.path variable and parse it with
awk.

Alternatively, you can parse the head response where the
content-disposition header is. To get the intended filename from the server.
Curl would use the remote name if -J, --remote-header-name is being used.

When using -o the filename is custom anyway. in this case you are probably
using a script and will have the filename before submitting the curl

Over all I think you should use a Head Request, which is explicitly
designed for this purpose.

Bastian


On Wed, 17 Sept 2025, 01:18 Paul Gilmartin via curl-users, <
curl-users_at_lists.haxx.se> wrote:

> On 9/16/25 15:27, Paul Gilmartin via curl-users wrote:
> >
> > The following seems to transfer the entire 1.6 GB file,
> > despite the "--out-null":
> > ...
> I stand corrected. I relied on my wishful thinking
> rather than the man page. I had been wishing for a way
> to use --write-out '%{filename_effective}' without
> the expense of transferring a large file over the net.
>
> Is there a way? I had been using a read-only --output-dir
> go get the filename_effective.
>
> --
> Thanks,
> gil
>
> --
> Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-users
> Etiquette: https://curl.se/mail/etiquette.html
>


-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-users
Etiquette:   https://curl.se/mail/etiquette.html
Received on 2025-09-17