mirror of
https://github.com/jbranchaud/til
synced 2026-01-04 23:58:01 +00:00
Add Download A File With Curl as a Unix TIL
This commit is contained in:
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
|
||||
|
||||
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
||||
|
||||
_1451 TILs and counting..._
|
||||
_1452 TILs and counting..._
|
||||
|
||||
---
|
||||
|
||||
@@ -1387,6 +1387,7 @@ _1451 TILs and counting..._
|
||||
- [Display The Contents Of A Directory As A Tree](unix/display-the-contents-of-a-directory-as-a-tree.md)
|
||||
- [Do A Dry Run Of An rsync](unix/do-a-dry-run-of-an-rsync.md)
|
||||
- [Do Not Overwrite Existing Files](unix/do-not-overwrite-existing-files.md)
|
||||
- [Download A File With Curl](unix/download-a-file-with-curl.md)
|
||||
- [Enable Multi-Select Of Results With fzf](unix/enable-multi-select-of-results-with-fzf.md)
|
||||
- [Exclude A Command From The ZSH History File](unix/exclude-a-command-from-the-zsh-history-file.md)
|
||||
- [Exclude A Directory With Find](unix/exclude-a-directory-with-find.md)
|
||||
|
||||
23
unix/download-a-file-with-curl.md
Normal file
23
unix/download-a-file-with-curl.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# Download A File With Curl
|
||||
|
||||
Though I typically think of cURL as a way of hitting an API endpoint to check
|
||||
its headers or see what it returns, it can also be used as an alternative to
|
||||
`wget` to download a file.
|
||||
|
||||
With the `-O` option (short for `--remote-name`) we instruct cURL to save the
|
||||
contents of the remote file to a local file in the current directory _using the
|
||||
same name as the remote_.
|
||||
|
||||
Here is an example:
|
||||
|
||||
```bash
|
||||
$ curl -O https://www.apache.org/dist/db/derby/db-derby-10.17.1.0/db-derby-10.17.1.0-bin.zip.asc
|
||||
```
|
||||
|
||||
This creates a file in my current directory called
|
||||
`db-derby-10.17.1.0-bin.zip.asc`. Notice it only uses the last part of the path
|
||||
for the file name.
|
||||
|
||||
See `man curl` for more details.
|
||||
|
||||
[source](https://stackoverflow.com/questions/4572153/os-x-equivalent-of-linuxs-wget#comment84857090_4572158)
|
||||
Reference in New Issue
Block a user