Commands tagged curl (212)

  • Searches for web radio by submitted keyword and returns the station name and the link for listing . May be enhanced to read user's selection and submit it to mplayer. Show Sample Output

    echo "Keyword?";read keyword;query=""$keyword"";curl -s $query |awk -F '"' 'NR <= 4 {next}NR>15{exit}{sub(/,""$6)}{print i++" )"$2}'
    benyounes · 2010-05-03 00:44:10 7
  • 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 5
  • 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 2
  • 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 2
  • 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 2

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

  • 4
    date -s "$(curl -sD - | grep '^Date:' | cut -d' ' -f3-6)Z"
    casueps · 2019-12-20 10:10:14 55
  • 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 3
  • 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 20
  • 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 4
  • 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 2
  • 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 4
  • 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 3
  • 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 25

  • 3
    curl -s | grep -oP '(\d{1,3}\.){3}\d+'
    ciekawy · 2016-07-11 18:07:37 10

  • 3
    GITUSER=$(whoami); curl "${GITUSER}/starred?per_page=1000" | grep -o 'git@[^"]*' | xargs -L1 git clone
    Calcutta · 2022-06-25 20:39:12 268
  • 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 2
  • 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'
    mccalni · 2009-10-23 14:29:06 3
  • A function that takes a domain name as an argument Show Sample Output

    geo(){ curl -s "$(dig +short $1)"| sed '/^IP:/!d;s/<[^>][^>]*>//g'; }
    dennisw · 2009-11-12 17:14:09 24
  • 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 12
  • 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 3
  • 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 9
  • 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 3
  • 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 4
  • 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 2
  •  < 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

Copy a file using dc3dd and watch its progress (very nice alternative to dd)
Requires the dc3dd package - available at

command line calculator
simple function , floating point number is supported.

Convert seconds to [DD:][HH:]MM:SS
Converts any number of seconds into days, hours, minutes and seconds. sec2dhms() { declare -i SS="$1" D=$(( SS / 86400 )) H=$(( SS % 86400 / 3600 )) M=$(( SS % 3600 / 60 )) S=$(( SS % 60 )) [ "$D" -gt 0 ] && echo -n "${D}:" [ "$H" -gt 0 ] && printf "%02g:" "$H" printf "%02g:%02g\n" "$M" "$S" }

set your ssd disk as a non-rotating medium
if you still get a permissions error using sudo, then nano the file: sudo nano -w /sys/block/sdb/queue/rotational and change 1 to 0 this thread: says that this will "help the block layer to optimize a few decisions"

To have only unique lines in a file

Insert a line at the top of a text file without sed or awk or bash loops
Yet another way to add a line at the top a of text file with the help of the tac command (reverse cat).

Decreasing the cdrom device speed
Decreasing the cdrom device speed may be more comfortable to watch films (for example)

Renaming a file without overwiting an existing file name
Sometimes in a hurry you may move or copy a file using an already existent file name. If you aliased the cp and mv command with the -i option you are prompted for a confirmation before overwriting but if your aliases aren't there you will loose the target file! The -b option will force the mv command to check if the destination file already exists and if it is already there a backup copy with an ending ~ is created.

Avoids ssh timeouts by sending a keep alive message to the server every 60 seconds
ssh_config is the system-wide configuration file for ssh. For per-user configuration, which allows for different settings for each host: $echo 'ServerAliveInterval 60' >> ~/.ssh/ssh_config On OSX: $echo 'ServerAliveInterval 60' >> ~/.ssh/config or $echo 'ServerAliveInterval 60' >> ~/etc/ssh_config

shows the full path of shell commands

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: