Commands tagged curl (206)

  • Each file in the current folder is uploaded to If the folder contains other filetypes change: for files in * to: for files in *.jpg (to upload ONLY .jpg files) Additionally you can try (results may vary): for files in *.jpg *.png The output URL is encased with BB image tags for use in a forum. Show Sample Output

    imageshack() { for files in *; do curl -H Expect: -F fileupload="@$files" -F xml=yes -# "" | grep image_link | sed -e 's/<image_link>/[IMG]/g' -e 's/<\/image_link>/[\/IMG]/g'; done; }
    operatinghazard · 2010-10-01 06:50:04 1
  • Shorter and made into a function. Show Sample Output

    googl () { curl -s -d "url=${1}" | sed -n "s/.*:\"\([^\"]*\).*/\1\n/p" ;}
    dabom · 2010-10-03 02:52:44 0
  • Just add this function to your .zshrc / .bashrc, and by typing "shout *URL*" you get a randomly chosen English word that uses to short your URL. You may now go to*output_word* and get redirected. The URL will be valid for 5 minutes. (I've never used sed before, so I'll be quite glad if someone could straighten up the sed commands and combine them (perhaps also removing the whitespace). If so, I'll update it right away ;) ) Show Sample Output

    shout () { curl -s "$1" | sed -n 's/\<h1\>/\&/p' | sed 's/<[^>]*>//g;/</N;//b' ;}
    elfreak · 2010-10-04 23:50:54 0
  • like 7300, but doesn't clutter your working directory with old qr.*.png files. This will get the QR barcode, and send it right into ImageMagick's 'display' tool. Usage is the same as 7300; just call this function followed by the URL: qrurl

    qrurl() { curl -sS "|0&chl=$1" -o - | display -filter point -resize 600x600 png:-; }
    __ · 2010-12-16 04:42:05 0

  • 4
    curl -I
    cfy · 2011-03-27 14:27:23 0

  • 4
    date -s "$(curl -sD - | grep '^Date:' | cut -d' ' -f3-6)Z"
    casueps · 2019-12-20 10:10:14 5
  • That makes a function you can put in your ~/.bashrc to run it when you need in any term with an IP as argument Show Sample Output

    GeoipLookUp(){ curl -A "Mozilla/5.0" -s "$1" | grep "^IP.*$1" | html2text; }
    sputnick · 2009-11-06 00:32:27 1
  • use curl and sed to shorten an url via

    curl -s ''"$1" | sed -e 's/{"short_url":"//' -e 's/"}/\n/g'
    mvrilo · 2010-03-26 22:31:06 4
  • runs an rss feed through sed replacing the closing tags with newlines and the opening tags with white space making it readable. Show Sample Output

    curl --silent "FEED ADDRESS" |sed -e 's/<\/[^>]*>/\n/g' -e 's/<[^>]*>//g
    ljmhk · 2011-04-11 14:08:50 1
  • Just an alternative with more advanced formating for readability purpose. It now uses colors (too much for me but it's a kind of proof-of-concept), and adjust columns. Show Sample Output

    curl -u username --silent "" | awk 'BEGIN{FS="\n";RS="(</entry>\n)?<entry>"}NR!=1{print "\033[1;31m"$9"\033[0;32m ("$10")\033[0m:\t\033[1;33m"$2"\033[0m"}' | sed -e 's,<[^>]*>,,g' | column -t -s $'\t'
    frntn · 2011-10-15 23:15:52 0
  • required packages: curl, xml2, html2text command is truncated, see 'sample output' Show Sample Output

    open R,"curl -s|xml2|"; while(<R>){ chomp; m(^/rss/channel/item/title=) and do{ s/^.*?=//; ($t,$d,$l)=($_,undef,undef) }; m(^/rss/channel/item/description=) and do{ s/^.*?=//; push @d,$_ }; m(^/rss/channel/item
    bandie91 · 2012-02-24 23:40:02 2
  • Watches the headers of a curl, following any redirects and printing only the HTTP status and the location of the possible redirects. Show Sample Output

    watch 'curl -s --location -I | grep -e "\(HTTP\|Location\)"'
    theist · 2012-04-23 17:05:29 0
  • With the "--resolve" switch, you can avoid doing DNS lookups or edit the /etc/hosts file, by providing the IP address for a domain directly. Useful if you have many servers with different IP addresses behind a load balancer. Of course, you would loop it: for IP in 10.11.0.{1..10}; do curl --resolve$IP -I -s; done

    curl --resolve -I -s
    atoponce · 2013-01-24 19:50:26 0

  • 3
    curl -s | grep -oP '(\d{1,3}\.){3}\d+'
    ciekawy · 2016-07-11 18:07:37 0
  • miss a class at UTOSC2010? need a refresher? use this to curl down all the presentations from the UTOSC website. ( NOTE/WARNING this will dump them in the current directory and there are around 37 and some are big - tested on OSX10.6.1 Show Sample Output

    b=""; for p in $( curl -s $b/presentation/schedule/ | grep /presentation/[0-9]*/ | cut -d"\"" -f2 ); do f=$(curl -s $b$p | grep "/static/slides/" | cut -d"\"" -f4); if [ -n "$f" ]; then echo $b$f; curl -O $b$f; fi done
    danlangford · 2009-10-11 17:28:46 0
  • Alternative to the ping check if your firewall blocks ping. Uses curl to get the landing page silently, or fail with an error code. You can probably do this with wget as well. Show Sample Output

    curl -fs 2&>1 > /dev/null || echo ping failed | mail -ne -s'Server unavailable' [email protected]
    mccalni · 2009-10-23 14:29:06 0
  • Requires display. Corrected version thanks to sputnick and eightmillion user.

    display$(curl -s|grep -Po '"\K/dyn/str_strip(/0+){4}/.*strip.[^\.]*\.gif')
    wizel · 2009-12-05 19:35:27 9
  • This version prints current votes and commands for a user. Pass the user as an argument. While this technically "fits" as a one liner, it really is easier to look at as a shell script with extra whitespace. :) Show Sample Output

    curl -s$1/xml | awk -F'</?div[^>]*>' '/class=\"command\"/{gsub(/&quot;/,"\"",$2); gsub(/&lt;/,"<",$2); gsub(/&gt;/,">",$2); gsub(/&amp;/,"\\&",$2); cmd=$2} /class=\"num-votes\"/{printf("%3i %s\n", $2, cmd)}'
    putnamhill · 2010-02-16 17:24:45 1
  • This will tell you which twitter user you are chronologically. For example, a number of 500 means you were the 500th user to create a twitter account. Show Sample Output

    curl -s | grep 'id="user_' | grep -o '[0-9]*'
    spiffwalker · 2010-04-04 18:43:14 7
  • There's another version on here that uses GET but some people don't have lwp-request, so here's an alternative. It's also a little shorter and should work with most youtube URLs since it truncates at the first &

    url="[Youtube URL]"; echo $(curl ${url%&*} 2>&1 | grep -iA2 '<title>' | grep '-') | sed 's/^- //'
    rkulla · 2010-04-29 02:03:36 1
  • In this example 'git' is the user name and the output format is YAML but you can change this to XML or JSON, eg: curl Show Sample Output

    rkulla · 2010-05-30 00:18:00 0
  • In this example we search for 'vim' but vim doesn't have a project on github right now. That's ok, this command still searches for every project that has 'vim' in their description (forks, plugins, etc). To get XML or JSON output just replace 'yaml' in the url with 'xml' or 'json'. Show Sample Output

    rkulla · 2010-05-30 00:29:03 0

  • 2
    curl -s "|en&v=1.0&q=`xsel`" |cut -d \" -f 6
    eneko · 2010-06-11 21:38:26 0
  • Query the Socrata Open Data API being used by the White House to find any employee's salary using curl, grep and awk. Change the value of the search parameter (example uses Axelrod) to the name of any White House staffer to see their annual salary. Show Sample Output

    curl -s "" | grep "data\" :" | awk '{ print $17 }'
    mheadd · 2010-07-01 23:54:54 2
  • Just add this to your .bashrc file. Use quotes when query has multiple word length. Show Sample Output

    findlocation() { place=`echo $1 | sed 's/ /%20/g'` ; curl -s "$place" | grep -e "address" -e "coordinates" | sed -e 's/^ *//' -e 's/"//g' -e 's/address/Full Address/';}
    shadyabhi · 2010-10-18 21:11:42 3
  •  < 1 2 3 4 5 >  Last ›

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Check These Out

fdiff is a 'filtered diff'. Given a text filter and two inputs, will run the filter across the input files and diff the output.
Fdiff will run the command given by the first argument against the input files given as the second and third arguments, and diff the results. It will use 'diff' as the default diff program, but this can be changed by setting $DIFFCMD, e.g. $ export DIFFCMD=vimdiff; $ fdiff zcat 0716_0020005.raw.gz 0716_0030005.raw.gz ... This function will work under bash, but requires the use of command substitution, which is not available under a strict ANSI shell.

search ubuntu packages to find which package contains the executable program programname
search ubuntu's remote package source repositories for a specific program to see which package contains it

easily strace all your apache processes
This version also attaches to new processes forked by the parent apache process. That way you can trace all current and *future* apache processes.

convert unixtime to human-readable
Mac have direct conversion of seconds (Epoch time)

Zip a directory on Mac OS X and ignore .DS_Store (metadata) directory
If you want to generate a cross-platform compatible zip file and ignore the Finder's hidden metadata directory

How to estimate the storage size of all files not named *.[extension] on the current directory
With this sentence we can estimate the storage size of all files not named *.jpg on the current directory. The syntax is based on Linux, for Unix compliance use: find ./* -prune ! -name '*.jpg' -ls |awk '{TOTAL+=$7} END {print int(TOTAL/(1024^2))"MB"}' We can change the jpg extension for whatever extension what we need

prints line numbers
the sed way to print line numbers

Binary injection
Replace (as opposed to insert) hex opcodes, data, breakpoints, etc. without opening a hex editor. HEXBYTES contains the hex you want to inject in ascii form (e.g. 31c0) OFFSET is the hex offset (e.g. 49cf) into the binary FILE

Netstat Connection Check
This command does a tally of concurrent active connections from single IPs and prints out those IPs that have the most active concurrent connections. VERY useful in determining the source of a DoS or DDoS attack.

Convert CSV to JSON
Replace 'csv_file.csv' with your filename.

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: