Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use curl -o filename URL to download a response to a known local file. Use -O when you want cURL to derive the filename from the URL, -L for redirects, and -C - to resume an interrupted transfer. The examples below cover single files, authentication, SFTP, multiple URLs, URL lists, troubleshooting, and safer repeatable downloads.

Download a file with cURL

cURL transfers data to or from a server using a URL. If you do not select an output option, it writes the response body to standard output, which is your terminal in a normal shell.

Stream the response to standard output

curl https://example.com/file.zip

This is suitable for text you intend to inspect or pipe to another command. Do not use it for a binary archive, image, installer, or disk image unless you redirect the output deliberately; binary bytes can corrupt your terminal display.

Save to an exact filename with -o

curl -o report.zip https://example.com/download?id=42

-o (also written --output) takes the path of the local destination. It is the safest default when the URL is an API endpoint, contains a query string, or ends in a generic path such as /download.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Lexar D40E 128GB Dual USB 3.2 Gen 1 Type-C Jump Drive, Champagne Silver
  • USB-C 2-in-1 storage OTG: The Lexar JumpDrive Dual Drive D40E features USB Type-A and Type-C connectors in a slim, portable form factor for easy device compatibility
  • Transfer speeds up to 100MB/s: Based on internal testing, performance may vary depending upon the host device, interface, and usage conditions. 1MB=1,000,000 bytes
  • Plug and Play: Widely compatible with USB Type-C smartphones, tablets, laptops, Macs, and traditional Type-A devices, no software installation required. The 360° swivel design allows for easy switching between connectors without the hassle of losing a cap
  • Durable & Compact: The Lexar D40E USB memory stick features a metal enclosure, withstands temperatures from 0° to 50° C (32°F to 122°F), and is lightweight at 26g with dimensions of 70.4 x 16.9 x 11.7mm
  • Security & Warranty: Securely protects files using an advanced security software solution with 256-bit AES encryption. Backed by a Lexar 3-year limited warranty

You can provide a directory as part of the path, but the directory must already exist:

mkdir -p downloads
curl -o downloads/report.zip https://example.com/download?id=42

Use the URL’s filename with -O

curl -O https://example.com/releases/app-1.2.3.tar.gz

-O (also --remote-name) saves the file component of the URL in the current working directory. In this example the local file is app-1.2.3.tar.gz. Check the directory first: an existing file can be replaced, depending on the transfer and options you use. When the URL does not contain a useful filename, use -o instead.

Handle redirects and inspect what the server returned

Follow redirects with -L

curl -L -o latest.zip https://example.com/latest

Download endpoints commonly redirect to a versioned object-storage URL or a sign-in route. cURL does not follow HTTP redirects unless asked, so add -L (or --location) when the endpoint is expected to redirect.

Show response headers while diagnosing a download

curl -i -L -o latest.zip https://example.com/latest

-i (or --include) places response headers in the output stream along with the body. That is useful for seeing status codes, Location headers, content type, and server-side errors. Because headers are mixed with the body, do not use this form for a file you need to consume as an unmodified archive. For cleaner diagnostics, run a separate header request or save the body with a normal command after you have identified the problem.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Resume an interrupted download

Continue from the existing local file

curl -C - -o large.iso https://example.com/large.iso

-C - asks cURL to determine the resume position from the existing local file and request the remainder. Pair it with -o so the local name is deterministic. If the transfer completed, cURL may report that there is nothing to resume.

Resume is not guaranteed for every server or protocol. The remote resource must support the required range behavior, and the local file must correspond to the same version of the resource. If the server rejects the range request, start a fresh download to a different filename rather than appending unrelated bytes.

Rank #2
KOOTION USB C Flash Drive 32GB 2 in 1 OTG USB 3.0/Type C Thumb Drive Dual Drive USB C Memory Stick for Smartphone Laptop Tablet PC, Blue
  • 2 in 1: USB C + USB 3.0, 32GB usb c flash drive has dual ports, usb 3.0 port is applied to all devices which have usb 3.0 interface and usb c port is widely used in all Android smartphones with OTG function
  • High Speed USB 3.0: Read speed up to 90 MB/s, Write speed up to 30 MB/s, the speed of USB 3.0 interface is faster than USB 2.0, save time to wait, increases work productivity. Note: Speed will be limited if you use the USB key in the USB 2.0 interface
  • Large Compatibility: The USB 3.0 Connector is compatible with USB 3.0 & USB 2.0 backward USB 1.1 devices, such as Laptop, Desktop, Car Audio, Tablet, TV, Speakers, Projector. USB-C port is compatible with all Android Smartphones
  • Expand Storage: Good performance in storing, transferring and sharing digital data with families, friends, colleagues, customers. It can expand the capacity of smartphone, you can watch movies or share pictures when you go on vacation with your family
  • Note: Make sure your smartphone is equipped with OTG function and need to open OTG function in Settings when you plug memory stick, then you can transfer easily data bewteen different devices

Protect a partial file from being mistaken for a complete one

Download to a temporary name and rename it only after cURL succeeds:

curl -fL -o large.iso.part https://example.com/large.iso && mv large.iso.part large.iso

-f (or --fail) makes an HTTP error status cause a failure instead of treating an error page as a successful file. The temporary-file pattern is especially useful in scripts that other processes monitor.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Download protected files

HTTP basic authentication

curl -u alice -o private.zip https://example.com/private.zip

-u (or --user) accepts USER[:PASSWORD]. Supplying only alice makes cURL prompt for the password, keeping it out of the command text and, in many environments, out of shell history. Avoid putting a password directly in a command line that may be logged or visible to other users.

curl -u 'alice:correct-horse-battery-staple' -o private.zip https://example.com/private.zip

The second form works, but the secret can be exposed through history, process listings, CI logs, or copied transcripts. Prefer an interactive prompt or the secret-management mechanism provided by your automation platform.

Other HTTP credentials and headers

Some services use a bearer token or an API key rather than basic authentication. Pass the exact header required by that service:

curl -fL -H 'Authorization: Bearer YOUR_TOKEN' -o data.json https://api.example.com/export

Use HTTPS and verify the host before sending credentials. Do not paste an untrusted URL into a command that expands shell substitutions, and quote URLs containing characters such as &, ?, $, or parentheses.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Lexar D40E 64GB Dual USB 3.2 Gen 1 Type-C Jump Drive, Champagne Silver
  • USB-C 2-in-1 storage OTG: The Lexar JumpDrive Dual Drive D40E features USB Type-A and Type-C connectors in a slim, portable form factor for easy device compatibility
  • Transfer speeds up to 100MB/s: Based on internal testing, performance may vary depending upon the host device, interface, and usage conditions. 1MB=1,000,000 bytes
  • Plug and Play: Widely compatible with USB Type-C smartphones, tablets, laptops, Macs, and traditional Type-A devices, no software installation required. The 360° swivel design allows for easy switching between connectors without the hassle of losing a cap
  • Durable & Compact: The Lexar D40E USB memory stick features a metal enclosure, withstands temperatures from 0° to 50° C (32°F to 122°F), and is lightweight at 26g with dimensions of 70.4 x 16.9 x 11.7mm
  • Security & Warranty: Securely protects files using an advanced security software solution with 256-bit AES encryption. Backed by a Lexar 3-year limited warranty

SFTP with an SSH key

curl -u username: --key ~/.ssh/id_rsa -o file.txt sftp://example.com/path/file.txt

The empty value after the colon tells cURL not to use a password in the command. cURL can then use the specified private key; an encrypted key may still prompt for its passphrase. Confirm that the account, host key, key permissions, and remote path are correct before troubleshooting the transfer itself.

Download several files in one command

Use a remote filename for each URL

curl -O https://example.com/a.txt -O https://example.com/b.txt

Each -O applies to the URL that follows it, so the files are saved as a.txt and b.txt in the current directory.

Assign explicit local names

curl https://example.com/a.txt -o a-local.txt 
     https://example.com/b.txt -o b-local.txt

Give every URL its own output choice when names must be predictable. This avoids collisions when two URLs use the same final path or when a URL has no filename at all.

Run transfers concurrently

curl --parallel 
     -o a-local.txt https://example.com/a.txt 
     -o b-local.txt https://example.com/b.txt

Without --parallel, transfers are sequential by default. Parallel requests can reduce elapsed time when the server and your network can handle them, but they also increase simultaneous load and can trigger rate limits. Use a modest set of URLs and follow the service’s usage policy.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Download URLs listed in a file

Newer cURL releases support URL-list input:

curl --url @urls.txt

Put one complete URL per line in urls.txt. The man page documents implicit remote-name behavior for this form beginning with cURL 8.13.0. Check your installed version before relying on it:

curl --version

If your build is older or behaves differently, use a shell loop with an explicit output policy instead of assuming that filenames will be chosen safely. Treat the list as data: do not place shell commands in it, and quote each URL when processing it in a script.

Rank #4
2-Pack 128GB USB C Flash Drive Dual Type C + USB A Memory Stick Jump Drive 2-in-1 Thumb Drive for Storage and Backup (128GB*2 Black&Blue)
  • 2-in-1 Dual Design: Features both USB-C and USB-A connectors, making it compatible with phones, tablets, MacBooks, PCs, and laptops-no adapter needed
  • Wide Compatibility: Works seamlessly with USB A and USB C devices, ensuring reliable file transfers across smartphones, computers, and more
  • Ample Storage Options: Available in 16GB/32GB/64GB/128GB providing plenty of space for photos, videos, music, and documents
  • Portable & Lightweight: Compact and durable design for travel, school, or daily use-take your files anywhere
  • Plug-and-Play Convenience: No software or drivers required; simply insert into USB-C or USB-A ports and start transferring files instantly

Choose options for reliable scripted downloads

Goal Option Example Why it matters
Exact destination -o FILE curl -o build.zip URL Works even when the URL has a query string or generic path.
URL-derived destination -O curl -O URL Uses the filename in the URL path.
Follow redirects -L curl -L -o file URL Handles HTTP redirection to the actual resource.
Inspect status and headers -i curl -i -L URL Exposes response headers for troubleshooting; do not save this mixed stream as a clean binary.
Resume -C - curl -C - -o file URL Requests continuation from the existing local length when the server supports it.
Fail on HTTP errors -f curl -fL -o file URL Prevents a typical HTTP error page from being accepted as the download.
Authenticate -u USER[:PASSWORD] curl -u alice URL Prompts for a password when only the username is supplied.
Concurrent URLs --parallel curl --parallel URL1 URL2 Runs transfers concurrently instead of sequentially.

For long-running jobs, combine the smallest set of options that expresses your policy. For example, -fL handles HTTP failures and redirects, while -o gives the job a stable destination. Add resume only when you know the endpoint supports it.

Or skip the browser setup

If your goal is to download a rendered website image or PDF rather than a file already hosted at a stable URL, ScreenshotNeo provides a website screenshot API and MCP server for developers. One GET request returns a PNG, JPEG, WebP, or PDF, so you can save the response with the same cURL output techniques shown above.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read the parameter details in the ScreenshotNeo documentation. A direct cURL request is:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

The equivalent requests in Python and Node.js are useful when the download is part of a larger program:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

Before capture, ScreenshotNeo accepts the cookie or consent banner like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and the response identifies the page verdict and billing status in X-Page-Verdict and X-Billed headers. Its MCP server includes take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. The Free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000. Sign up for the free ScreenshotNeo plan.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common cURL download failures

The terminal fills with unreadable characters

You streamed binary data to standard output. Repeat the command with -o filename or -O. If the file was redirected into a shell pipeline, delete the damaged output and download it again.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The saved file is an HTML error page

The URL may require a redirect, authentication, or a different path. Run curl -i -L URL to inspect the status and headers, then use -fL for the real download so an HTTP error causes a nonzero exit status. Check that you are not saving a login page returned after an unauthenticated request.

Best Value
Samsung Type-C USB Flash Drive 256GB, USB 3.2 Gen 1, Up to 400MB/s
  • USB-C STORAGE ON THE GO: This sleek drive is supported by Samsung NAND flash and is incredibly compact to fit in the palm of your hand; Count on reliable performance and fast transfer speeds while staying compact
  • PERFORMANCE WITH SPEED: No need to choose between performance and reliability; Experience a fast, powerful flash drive that transfers 4GB files in just 11 seconds with up to 400MB/s USB 3.2 Gen 1 read speeds and is backward compatible with USB 3.0/2.0
  • MODERN MEETS ICONIC: The ultra-sleek USB-C drive looks as good as it performs; Featuring a reversible plug, the Type-C inserts into your devices seamlessly every time; Transfer large files with style and ease
  • ALWAYS CONNECTED: USB-C is compatible across devices, including laptops, tablets, phones and cameras, with enough space for 63,730 photos or maximum 12 hours of 4K video; With up to 256GB of storage space, this pocket-sized thumb drive comes in handy wherever you go
  • TOUGH & TRUSTED: Files stay secure, no matter the terrain; Samsung's flash memory technology makes the Type-C a trustworthy drive to store your valuable data; It's waterproof, shock-proof, magnet-proof, temperature-proof, and X-ray-proof body, plus it's backed by a 5-year limited warranty

The command creates the wrong filename

Use -o with an explicit path. -O deliberately derives the name from the URL path and cannot infer the filename you intended from an API’s query parameters.

Resume fails or starts over

The server or protocol may not support range requests, the remote file may have changed, or the local partial file may not match it. Keep the partial file, try once with -C -, and if the server rejects continuation, download afresh to a new temporary name.

Several downloads overwrite each other

Two URLs may resolve to the same remote filename. Replace -O with a distinct -o for every URL, and place each destination in the command next to its URL.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Credentials work interactively but fail in automation

Check which authentication scheme the server expects. A basic-auth -u argument will not substitute for a bearer header, signed URL, cookie, or client certificate. Supply secrets through your CI or operating system secret store rather than embedding them in a script or command line.

The URL works in a browser but not in cURL

Confirm the exact URL, quote shell metacharacters, and test redirects with -L. The browser may also be sending cookies, authorization headers, a user agent, or a JavaScript-generated URL that cURL does not have. Reproduce only the headers and credentials you are authorized to use.

Verify and handle downloaded files safely

  • Prefer HTTPS and verify the expected host before supplying credentials.
  • Download archives and executables to a temporary path, then inspect them before opening or running them.
  • Use the publisher’s checksum or signature when one is provided; do not assume that a successful HTTP transfer proves the file’s authenticity.
  • Quote URLs containing shell metacharacters, and never paste untrusted command substitutions into a shell.
  • Check curl --version and curl --manual when a feature may depend on your installed version or build.

A practical command checklist

  1. Confirm the URL and expected host, preferably over HTTPS.
  2. Decide whether the destination should be an explicit name (-o) or the URL’s name (-O).
  3. Add -L if the endpoint can redirect.
  4. Use -f in scripts so HTTP failures are not mistaken for successful files.
  5. Use -C - only with a matching partial file and a server that supports resuming.
  6. For multiple URLs, assign each output explicitly or use remote names that you have checked for collisions.
  7. Inspect, verify, and safely handle the resulting file before opening it.

Frequently Asked Questions

How can I see which cURL version supports a download option?

Run curl --version for the installed release and protocol features, then read the matching local manual with curl --manual. Options such as URL-list input can be version-sensitive.

Should I use -O for downloads in production scripts?

Use -O only when URL-derived names are intentional and collision-free. For repeatable jobs, -o with an explicit path makes the destination and overwrite behavior easier to audit.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.