diff --git a/README.md b/README.md index 64ba198..d447598 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/unix/download-a-file-with-curl.md b/unix/download-a-file-with-curl.md new file mode 100644 index 0000000..aae69ee --- /dev/null +++ b/unix/download-a-file-with-curl.md @@ -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)