Commands tagged curl (206)

  • curl -> IP Adress curl -> Remote Host curl ->User Agent curl -> Port thonks to

    aajjk · 2010-04-21 13:10:33 10
  • Checks the Gmail ATOM feed for your account, parses it and outputs a list of unread messages. For some reason sed gets stuck on OS X, so here's a Perl version for the Mac: curl -u username:password --silent "" | tr -d '\n' | awk -F '<entry>' '{for (i=2; i<=NF; i++) {print $i}}' | perl -pe 's/^<title>(.*)<\/title>.*<name>(.*)<\/name>.*$/$2 - $1/' If you want to see the name of the last person, who added a message to the conversation, change the greediness of the operators like this: curl -u username:password --silent "" | tr -d '\n' | awk -F '<entry>' '{for (i=2; i<=NF; i++) {print $i}}' | perl -pe 's/^<title>(.*)<\/title>.*?<name>(.*?)<\/name>.*$/$2 - $1/' Show Sample Output

    curl -u username:password --silent "" | tr -d '\n' | awk -F '<entry>' '{for (i=2; i<=NF; i++) {print $i}}' | sed -n "s/<title>\(.*\)<\/title.*name>\(.*\)<\/name>.*/\2 - \1/p"
    postrational · 2009-09-07 21:56:40 12
  • Change Seville for your prefered city. Show Sample Output

    nordri · 2016-08-28 09:43:38 10

  • 25
    curl -Is | egrep '^X-(F|B|L)' | cut -d \- -f 2
    icco · 2009-03-23 19:58:10 8
  • This function displays the latest comic from One of the best things about xkcd is the title text when you hover over the comic, so this function also displays that after you close the comic. To get a random xkcd comic, I also use the following: xkcdrandom(){ wget -qO-|tee >(feh $(grep -Po '(?<=")http://imgs[^/]+/comics/[^"]+\.\w{3}'))|grep -Po '(?<=(\w{3})" title=").*(?=" alt)';}

    xkcd(){ wget -qO-|tee >(feh $(grep -Po '(?<=")http://imgs[^/]+/comics/[^"]+\.\w{3}'))|grep -Po '(?<=(\w{3})" title=").*(?=" alt)';}
    eightmillion · 2009-11-27 09:11:47 11
  • Yeah I know it's been up here a million times, but this service is a really clean and nice one. Nothing but your IP address on it. Actually I was to write something like this, and noticed this on appspot... ;) Show Sample Output

    ktoso · 2009-10-31 21:11:10 2
  • This function takes a word or a phrase as arguments and then fetches definitions using Google's "define" syntax. The "nl" and perl portion isn't strictly necessary. It just makes the output a bit more readable, but this also works: define(){ local y="$@";curl -sA"Opera" "${y// /+}"|grep -Po '(?<=<li>)[^<]+';} If your version of grep doesn't have perl compatible regex support, then you can use this version: define(){ local y="$@";curl -sA"Opera" "${y// /+}"|grep -Eo '<li>[^<]+'|sed 's/<li>//g'|nl|perl -MHTML::Entities -pe 'decode_entities($_)' 2>/dev/null;} Show Sample Output

    define(){ local y="$@";curl -sA"Opera" "${y// /+}"|grep -Po '(?<=<li>)[^<]+'|nl|perl -MHTML::Entities -pe 'decode_entities($_)' 2>/dev/null;}
    eightmillion · 2010-01-29 05:01:11 5
  • A bash function might also be useful: dict() { curl dict://$1; } Or if you want less verbose output: dict() { curl -s dict://$1 | perl -ne 's/\r//; last if /^\.$/; print if /^151/../^250/'; } Show Sample Output

    curl dict://
    HorsePunchKid · 2009-04-10 18:12:37 1

  • 15
    check(){ curl -sI $1 | sed -n 's/Location: *//p';}
    putnamhill · 2010-09-30 12:29:02 1

  • 14
    curl -u username -o bookmarks.xml
    avi4now · 2009-04-06 13:54:15 3
  • An improvement of the original (at: in the sense that you see a "from cURL" under your status message instead of just a "from API" ;-) Twitter automatically links it to the cURL home page. Show Sample Output

    curl -u twitter-username -d status="Hello World, Twitter!" -d source="cURL"
    MyTechieself · 2009-12-08 14:54:33 1
  • Required curl version >=7.21; using ~/.netrc for authorization

    curl -n --ssl-reqd --mail-from "<>" --mail-rcpt "<user@server.tld>" --url smtps:// -T file.txt
    mitry · 2010-10-03 15:44:53 16
  • Validates and pretty-prints the content fetched from the URL. Show Sample Output

    curl -s "" | python -m json.tool | less -R
    keimlink · 2010-03-24 09:15:12 3
  • Curl is not installed by default on many common distros anymore. wget always is :) wget -qO-

    wget -qO-
    SuperJediWombat · 2010-06-24 03:49:14 1
  • Retrieve the current stock price from Yahoo Finance. The output is simply the latest price (which could be delayed). If you want to look up stock for a different company, replace csco with your symbol. Show Sample Output

    curl -s ''
    haivu · 2009-05-04 08:13:59 12

  • 11
    dpoblador · 2010-10-09 08:12:26 0

  • 11
    curl -I http://localhost
    mniskin · 2011-01-02 14:19:30 0
  • They are using json now Show Sample Output

    curl -s | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["world"]["population"]'
    mfr · 2013-07-27 08:00:10 0
  • Use `zless` to read the content of your *rss.gz file: zless commandlinefu-contribs-backup-2009-08-10-07.40.39.rss.gz Show Sample Output

    curl<your username>/rss|gzip ->commandlinefu-contribs-backup-$(date +%Y-%m-%d-%H.%M.%S).rss.gz
    linuxrawkstar · 2009-08-10 12:43:33 0

  • 9
    curl -s '' | sed 's/.*Current IP Address: \([0-9\.]*\).*/\1/g'
    kulor · 2009-08-06 11:54:31 1
  • This will log your internet download speed. You can run gnuplot -persist <(echo "plot 'bps' with lines") to get a graph of it.

    echo $(date +%s) > start-time; URL=; while true; do echo $(curl -L --w %{speed_download} -o/dev/null -s $URL) >> bps; sleep 10; done &
    matthewbauer · 2009-09-19 21:26:06 0
  • Not my script. Belongs to mathewbauer. Used without his permission. This script gives a single line as shown in the sample output. NOTE: I have blanked out the IP address for obvious security reasons. But you will get whatever is your IP if you run the script. Tested working in bash. Show Sample Output

    curl -s "$(curl -s" | sed '/^IP:/!d;s/<[^>][^>]*>//g'
    getkaizer · 2009-11-04 07:15:02 3
  • Gets all kind of info, rocks ... for just the ip addess you can use or Show Sample Output

    pykler · 2012-05-16 18:22:28 0

  • 8
    urls=('' ''); for i in ${urls[@]}; do http_code=$(curl -I -s $i -w %{http_code}); echo $i status: ${http_code:9:3}; done
    Code_Bleu · 2009-08-17 16:24:26 0
  • This function uploads images to and then prints out the links to the file. Some coloring can also be added to the command with: ompload() { curl -F file1=@"$1"|awk '/Info:|File:|Thumbnail:|BBCode:/{gsub(/<[^<]*?\/?>/,"");$1=$1;sub(/^/,"\033[0;34m");sub(/:/,"\033[0m:");print}';} Show Sample Output

    ompload() { curl -# -F file1=@"$1"|awk '/Info:|File:|Thumbnail:|BBCode:/{gsub(/<[^<]*?\/?>/,"");$1=$1;print}';}
    eightmillion · 2009-11-07 20:56:52 1
  •  1 2 3 >  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

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

check web server port 80 response header

Count threads of a jvm process
if you have problem threads problem in tomcat

Find broken symlinks in the current directory and its subdirectories.
This is best run as root to avoid permission denials that can produce false positives. Obviously you can specify a directory in the usual way: $ find -L dirname -type l I can't remember where I read about this or who deserves the credit for it. The find(1) manual page hints strongly toward it, however.

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

list all crontabs for users
additionally use "find /etc/cron*" for cronscripts

Backup all MySQL Databases to individual files
Backups all MySQL databases to individual files. Can be put into a script that grabs current date so you have per day backups.

Get own public IP address
Plain Text Ip Output, independent of Layout change.

Get AWS temporary credentials ready to export based on a MFA virtual appliance
You might want to secure your AWS operations requiring to use a MFA token. But then to use API or tools, you need to pass credentials generated with a MFA token. This commands asks you for the MFA code and retrieves these credentials using AWS Cli. To print the exports, you can use: `awk '{ print "export AWS_ACCESS_KEY_ID=\"" $1 "\"\n" "export AWS_SECRET_ACCESS_KEY=\"" $2 "\"\n" "export AWS_SESSION_TOKEN=\"" $3 "\"" }'` You must adapt the command line to include: * $MFA_IDis ARN of the virtual MFA or serial number of the physical one * TTL for the credentials

Find usb device in realtime
Using this command you can track a moment when usb device was attached.

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: