Created
August 18, 2022 13:04
-
-
Save mnebuerquo/e964c3f2c17c57c4894cb79575635bc1 to your computer and use it in GitHub Desktop.
curl-or-wget.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# this one saves to a file | |
download_file(){ | |
curl -f -o "${1}" "${2}" || wget -O "${1}" "${2}" | |
} | |
download_file /path/destination https://sourceurl | |
# this one uses stdout | |
download_pipe(){ | |
curl -f "${1}" 2>/dev/null || wget -q --output-document - "${1}" 2>/dev/null | |
} | |
download_pipe https://sourceurl | more |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment