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.