buymeasoda RefDocs
  • Overview
  • General
    • Android
    • Apache
    • Fish
    • Git
    • Github
    • Gmail
    • Homebrew
    • iOS
    • iTerm
    • MacOS
    • MacPorts
    • Mamp
    • Media
    • Mercurial
    • MySQL
    • Node
    • npm
    • nvm
    • Obsidian
    • PHP
    • React Native
    • Rust
    • Server
    • Slack
    • Sourcegraph
    • Tools
    • Vim
    • VS Code
    • Yarn
  • Unix
    • Checksum and hash utilities
    • Command line history
    • Command line keyboard shortcuts
    • Compress files and folders
    • Crontab
    • Diff files and folders
    • Disk usage and file sizes
    • Find and search files
    • Firewall configuration
    • Help and manual pages
    • HostName and Local HostName for Mac OSX
    • Navigating the file system
    • Network, domains and routing
    • Run and manage background tasks
    • Secure FTP SFTP and Secure Copy SCP
    • Secure Shell SSH
    • Sync files and folders
    • System and process management
    • System and user information
    • Useful characters
    • Useful commands
    • User, file and group permissions
    • Working with cURL
    • Working with files and directories
    • Working with text
Powered by GitBook
On this page
  • Downloading files
  • Sending requests
  1. Unix

Working with cURL

Downloading files

Download single file

curl <url>
curl http://www.google.com

Output downloaded result to a file

curl <url> > <file>
curl http://www.google.com > google.txt

curl -o <file> <url>
curl -o google.txt http://www.google.com

Output downloaded file based on destination file name (eg. about.html)

curl -O <url>
curl -O https://www.google.com/intl/en/about.html

Fetch and output multiple files

curl -O <url1> <url2> <url3>

Follow location headers

curl -L <url>
curl -L http://google.com

Verbose activity information

curl -v <url>
curl -v http://www.google.com

Resume partially downloaded file

curl -C - -O <url>

Sending requests

Send GET/POST request

curl -X <method> -H "<headers>" -d '<params>' <url>

Example: Send post request for JSON content type to GraphQL endpoint

curl -X POST \
  -H "Content-Type: application/json" \
  -d '{"query": "{ field }"}' \
  http://server/graphql
PreviousUser, file and group permissionsNextWorking with files and directories

Last updated 3 years ago