Download file

3 snippets across 2 stacks - Bash & Linux, HTML & CSS

Also written as file download

SHBash & Linux

Transfer Data with URLs

SH · Networking
Syntax
curl [options] URL
Example
curl https://api.example.com/users
curl -X POST -H 'Content-Type: application/json' -d '{"name":"Ada"}' https://api.example.com/users
curl -o release.tar.gz -L https://github.com/proj/repo/archive/v2.1.tar.gz

Note -o saves to a file, -O uses the remote filename. -L follows redirects (essential for GitHub downloads). -s silences progress bar. -I fetches only headers. -k skips TLS verification (use only for debugging, never in production).

Download Files

SH · Networking
Syntax
wget [options] URL
Example
wget https://releases.example.com/v3.1/app.deb
wget -c https://dumps.example.com/backup.sql.gz
wget -r -np -l 2 https://docs.example.com/manual/

Note -c resumes a partially downloaded file. -r downloads recursively, -np prevents ascending to the parent directory, -l sets recursion depth. wget is simpler than curl for straightforward downloads and supports resuming by default.

HCHTML & CSS

Download Links

HC · Links & Navigation
Syntax
<a href="file-url" download="filename">Download</a>
Example
<a href="/reports/q4-summary.pdf" download="Q4-Report.pdf">
  Download Q4 Report
</a>

Note The download attribute only works for same-origin URLs or blob/data URIs. Cross-origin files will open in the browser instead of downloading.

Frequently asked questions

How do you download file?
This task is covered in 2 stacks on this page: Bash & Linux, HTML & CSS. The "Transfer Data with URLs" snippet in Bash & Linux uses `curl [options] URL`.
Which command does the Bash & Linux example use?
The "Transfer Data with URLs" snippet uses `curl [options] URL`, from the Networking section of the Bash & Linux cheat sheet.
Which stacks cover "download file" on this page?
Bash & Linux, HTML & CSS. Together they hold 3 copy-ready snippets for this task.
Is there anything to watch out for?
Yes. For "Transfer Data with URLs": -o saves to a file, -O uses the remote filename. -L follows redirects (essential for GitHub downloads). -s silences progress bar. -I fetches only headers. -k skips TLS verification (use only for debugging, never in production).