30 examples for curl
# download a file and write it to another file called myfile.html curl -o myfile.html http://bropages.org
# Download a file using its original filename, follow all redirects, and continue where you left off if the download previously failed curl -LOC - http://foo.bar/file.ext
# Get my external IP address curl ifconfig.me/ip # Get my remote host curl ifconfig.me/host # Get my user agent curl ifconfig.me/ua # Get port curl ifconfig.me/port
# POST the JSON encoded object # { # "command": "sup", # "chill": true # } # with header 'X-BRO-HEADER' and value 91384934 to api.bro.com curl -X POST api.bro.com -d '{"command": "sup", "chill": true}' -H "X-BRO-HEADER: 91384934"
# Post a file to a shiny enterprise webservice api curl -d @invoice.pdf -X POST http://devnull-as-a-service.com/dev/null
# Get the header of a page. Very handy for checking HTTP status, such as redirects. Also, check out httpstatus.es as a quick reference. curl -I http://somapage.com
# Curl without progress bar, so you can pipe output curl -s http://path.to/resource | less curl -s http://path.to/resource | vim --
# POST the contents of a file (data.json in this example) curl -X POST -d @data.json http://httpbin.org/post
# Update Twitter curl -u user:pass -d status="Tweeting from the shell" http://twitter.com/statuses/update.xml
# Check Gmail curl -u username --silent "https://mail.google.com/mail/feed/atom" | perl -ne 'print "\t" if //; print "$2\n" if /<(title|name)>(.*)<\/\1>/;'
# Get the response time with cURL curl -o /dev/null -s -w %{time_total}\\n http://www.google.com
# POST a raw binary file with absolutely no extra processing curl --data-binary @"image.png" http://an.imageprocessor.com
# Run a curl and output the response headers to STDOUT curl -D - http://www.google.com -s -o /dev/null
# post form data as application/x-www-form-urlencoded (through the use of -d flag) curl -X POST -d "key1=val1&key2=val2" URL
# Read the headers of a request without submitting a HEAD request curl -sv "http://bropages.org" 1>/dev/null
# Send a header with curl and follow the bropages redirect curl --header "X-BeerIsInteresting: 1" www.bropages.org -L
# download filename.ext and automatically name it as filename.ext on disk curl -O http://domain.test/filename.ext
# download file from url keeping exact name curl -O [url] curl -O http://wallpapersrus.com/bigtitty.png
# Download http://test.com/file.txt and print it to stdout. curl -o - http://test.com/file.txt