xe1phix

commandlinefu.com_curl_commands_collection.sh

Oct 6th, 2022
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 15.46 KB | None | 0 0
  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Linux commands collection part1 ( www.commandlinefu.com )
  4. //
  5. // ---------------------------------------------------
  6. // http://www.commandlinefu.com/commands/browse
  7. //
  8. /////////////////////////////////////////////////////////////////////////////
  9.  
  10. *
  11. *
  12. *
  13. *
  14. *
  15. *
  16.  
  17. ----------------------------------------
  18.  
  19. curl ifconfig.me
  20. #Get your external IP address
  21.  
  22. curl -u user:pass -d status="Tweeting from the shell" http://twitter.com/statuses/update.xml
  23. #Update twitter via curl
  24.  
  25. curl -u username --silent "https://mail.google.com/mail/feed/atom" | perl -ne 'print "\t" if /<name>/; print "$2\n" if /<(title|name)>(.*)<\/\1>/;'
  26. #Check your unread Gmail from the command line
  27.  
  28. i="8uyxVmdaJ-w";mplayer -fs $(curl -s "http://www.youtube.com/get_video_info?&video_id=$i" | echo -e $(sed 's/%/\\x/g;s/.*\(v[0-9]\.lscache.*\)/http:\/\/\1/g') | grep -oP '^[^|,]*')
  29. #Stream YouTube URL directly to mplayer.
  30.  
  31. curl icanhazip.com
  32. #return external ip
  33.  
  34. cmdfu(){ curl "http://www.commandlinefu.com/commands/matching/$@/$(echo -n $@ | openssl base64)/plaintext"; }
  35. #Search commandlinefu.com from the command line using the API
  36.  
  37. curl -u username:password --silent "https://mail.google.com/mail/feed/atom" | tr -d '\n' | awk -F '<entry>' '{for (i=2; i<=NF; i++) {print $i}}' | sed -n "s/<title>\(.*\)<\/title.*name>\(.*\)<\/name>.*/\2 - \1/p"
  38. #Check your unread Gmail from the command line
  39.  
  40. curl ifconfig.me
  41. #What is my public IP-address?
  42.  
  43. curl -Is slashdot.org | egrep '^X-(F|B|L)' | cut -d \- -f 2
  44. #Gets a random Futurama quote from /.
  45.  
  46. curl ip.appspot.com
  47. #Get your external IP address
  48.  
  49. define(){ local y="$@";curl -sA"Opera" "http://www.google.com/search?q=define:${y// /+}"|grep -Po '(?<=<li>)[^<]+'|nl|perl -MHTML::Entities -pe 'decode_entities($_)' 2>/dev/null;}
  50. #Define words and phrases with google.
  51.  
  52. flight_status() { if [[ $# -eq 3 ]];then offset=$3; else offset=0; fi; curl "http://mobile.flightview.com/TrackByRoute.aspx?view=detail&al="$1"&fn="$2"&dpdat=$(date +%Y%m%d -d ${offset}day)" 2>/dev/null |html2text |grep ":"; }
  53. #track flights from the command line
  54.  
  55. curl -I www.commandlinefu.com
  56. #Get http headers for an url
  57.  
  58. ls | curl -F 'sprunge=<-' http://sprunge.us | xclip
  59. #Run a command, store the output in a pastebin on the internet and place the URL on the xclipboard
  60.  
  61. curl dict://dict.org/d:something
  62. #Look up the definition of a word
  63.  
  64. curl -s http://checkip.dyndns.org/ | grep -o "[[:digit:].]\+"
  65. #Get your public ip using dyndns
  66.  
  67. :w !curl -F "sprunge=<-" http://sprunge.us | xclip
  68. #Quickly share code or text from vim to others.
  69.  
  70. zenity --list --width 500 --height 500 --column 'radio' --column 'url' --print-column 2 $(curl -s http://www.di.fm/ | awk -F '"' '/href="http:.*\.pls.*96k/ {print $2}' | sort | awk -F '/|\.' '{print $(NF-1) " " $0}') | xargs mplayer
  71. #Choose from a nice graphical menu which DI.FM radio station to play
  72.  
  73. check(){ curl -sI $1 | sed -n 's/Location: *//p';}
  74. #See where a shortened url takes you before click
  75.  
  76. curl -u username -o bookmarks.xml https://api.del.icio.us/v1/posts/all
  77. #Download all Delicious bookmarks
  78.  
  79. URL="http://www.google.com";curl -L --w "$URL\nDNS %{time_namelookup}s conn %{time_connect}s time %{time_total}s\nSpeed %{speed_download}bps Size %{size_download}bytes\n" -o/dev/null -s $URL
  80. #How fast is the connexion to a URL, some stats from curl
  81.  
  82. curl --user login:password -o DeliciousBookmarks.xml -O 'https://api.del.icio.us/v1/posts/all'
  83. #backup delicious bookmarks++
  84.  
  85. function google { Q="$@"; GOOG_URL='https://www.google.de/search?tbs=li:1&q='; AGENT="Mozilla/4.0"; stream=$(curl -A "$AGENT" -skLm 10 "${GOOG_URL}${Q//\ /+}" | grep -oP '\/url\?q=.+?&amp' | sed 's|/url?q=||; s|&amp||'); echo -e "${stream//\%/\x}"; }
  86. #Google verbatim search on your terminal
  87.  
  88. curl -s http://checkip.dyndns.org | sed 's/[a-zA-Z<>/ :]//g'
  89. #Another Curl your IP command
  90.  
  91. for x in `jot - 0 2400 25`; do curl "http://www.commandlinefu.com/commands/browse/sort-by-votes/plaintext/$x" ; done > commandlinefu.txt
  92. #Get all these commands in a text file with description.
  93.  
  94. id="dMH0bHeiRNg";mplayer -fs http://youtube.com/get_video.php?video_id=$id\&t=$(curl -s http://www.youtube.com/watch?v=$id | sed -n 's/.*, "t": "\([^"]*\)", .*/\1/p')
  95. #Stream YouTube URL directly to mplayer
  96.  
  97. curl -u twitter-username -d status="Hello World, Twitter!" -d source="cURL" http://twitter.com/statuses/update.xml
  98. #Update twitter via curl (and also set the "from" bit)
  99.  
  100. curl -n --ssl-reqd --mail-from "<user@gmail.com>" --mail-rcpt "<user@server.tld>" --url smtps://smtp.gmail.com:465 -T file.txt
  101. #Send email with curl and gmail
  102.  
  103. curl -s 'http://download.finance.yahoo.com/d/quotes.csv?s=csco&f=l1'
  104. #Command Line to Get the Stock Quote via Yahoo
  105.  
  106. curl -u user -d status="Tweeting from the shell" http://twitter.com/statuses/update.xml
  107. #Update twitter via curl
  108.  
  109. curl http://www.whatismyip.org/
  110. #What is my ip?
  111.  
  112. curl -s "http://www.geody.com/geoip.php?ip=$(curl -s icanhazip.com)" | sed '/^IP:/!d;s/<[^>][^>]*>//g'
  113. #geoip information
  114.  
  115. curl -s "http://feeds.delicious.com/v2/json?count=5" | python -m json.tool | less -R
  116. #JSON processing with Python
  117.  
  118. curl ifconfig.me
  119. #Get My Public IP Address
  120.  
  121. imgur(){ $*|convert label:@- png:-|curl -F "image=@-" -F "key=1913b4ac473c692372d108209958fd15" http://api.imgur.com/2/upload.xml|grep -Eo "<original>(.)*</original>" | grep -Eo "http://i.imgur.com/[^<]*";}
  122. #Execute a command, convert output to .png file, upload file to imgur.com, then returning the address of the .png.
  123.  
  124. curl http://www.commandlinefu.com/commands/by/<your username>/rss|gzip ->commandlinefu-contribs-backup-$(date +%Y-%m-%d-%H.%M.%S).rss.gz
  125. #back up your commandlinefu contributed commands
  126.  
  127. while [ 1 ]; do curl -s -u username:password http://twitter.com/statuses/friends_timeline.rss|grep title|sed -ne 's/<\/*title>//gp' | head -n 6 |festival --tts; sleep 300;done
  128. #Speak the top 6 lines of your twitter timeline every 5 minutes.....
  129.  
  130. curl -sd q=Network http://www.commandlinefu.com/search/autocomplete |html2text -width 100
  131. #Search commandlinefu from the CLI
  132.  
  133. curl http://sohowww.nascom.nasa.gov/data/realtime/eit_195/512/latest.jpg | xli -onroot -fill stdin
  134. #Amazing real time picture of the sun in your wallpaper
  135.  
  136. echo $(date +%s) > start-time; URL=http://www.google.com; while true; do echo $(curl -L --w %{speed_download} -o/dev/null -s $URL) >> bps; sleep 10; done &
  137. #Log your internet download speed
  138.  
  139. curl http://www.commandlinefu.com/commands/browse/sort-by-votes/plaintext/[0-2500:25] | grep -v _curl_ > comfu.txt
  140. #Save the Top 2500 commands from commandlinefu to a single text file
  141.  
  142. d="www.dafont.com/alpha.php?";for c in {a..z}; do l=`curl -s "${d}lettre=${c}"|sed -n 's/.*ge=\([0-9]\{2\}\).*/\1/p'`;for((p=1;p<=l;p++));do for u in `curl -s "${d}page=${p}&lettre=${c}"|egrep -o "http\S*.com/dl/\?f=\w*"`;do aria2c "${u}";done;done;done
  143. #Fetch every font from dafont.com to current folder
  144.  
  145. dig +short @resolver1.opendns.com myip.opendns.com
  146. #Outgoing IP of server, Faster than the curl/wget-approaches.
  147.  
  148. curl ifconfig.me/all
  149. #Get your external IP and Network Info
  150.  
  151. curl -s http://www.census.gov/popclock/data/population/world | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["world"]["population"]'
  152. #Fetch the current human population of Earth
  153.  
  154. curl -s 'http://checkip.dyndns.org' | sed 's/.*Current IP Address: \([0-9\.]*\).*/\1/g'
  155. #Get your external IP address
  156.  
  157. urls=('www.ubuntu.com' 'google.com'); for i in ${urls[@]}; do http_code=$(curl -I -s $i -w %{http_code}); echo $i status: ${http_code:9:3}; done
  158. #Check availability of Websites based on HTTP_CODE
  159.  
  160. curl -I http://localhost
  161. #Send an http HEAD request w/curl
  162.  
  163. ompload() { curl -# -F file1=@"$1" http://ompldr.org/upload|awk '/Info:|File:|Thumbnail:|BBCode:/{gsub(/<[^<]*?\/?>/,"");$1=$1;print}';}
  164. #Upload images to omploader.org from the command line.
  165.  
  166. curl http://example.com/a.gz | tar xz
  167. #Extract tarball from internet without local saving
  168.  
  169. export QQ=$(mktemp -d);(cd $QQ; curl -s -O http://www.commandlinefu.com/commands/browse/sort-by-votes/plaintext/[0-2400:25];for i in $(perl -ne 'print "$1\n" if( /^(\w+\(\))/ )' *|sort -u);do grep -h -m1 -B1 $i *; done)|grep -v '^--' > clf.sh;rm -r $QQ
  170. #grab all commandlinefu shell functions into a single file, suitable for sourcing.
  171.  
  172. username=matthewbauer; curl -s http://www.commandlinefu.com/commands/by/$username/json | tr '{' '\n' | grep -Eo ',"votes":"[0-9\-]+","' | grep -Eo '[0-9\-]+' | tr '\n' '+' | sed 's/+$/\n/' | bc
  173. #Get your commandlinefu points (upvotes - downvotes)
  174.  
  175. curl -s ip.appspot.com
  176. #Get your outgoing IP address
  177.  
  178. step1 ; step2 ; step3 ; step4 ; curl -o- --get 'https://stream.twitter.com/1/statuses/filter.json' --header "$oauth_header" --data "follow=$id"
  179. #Get a stream feed from a Twitter user
  180.  
  181. Q="YOURSEARCH"; GOOG_URL="http://www.google.com/search?q="; AGENT="Mozilla/4.0"; stream=$(curl -A "$AGENT" -skLm 10 "${GOOG_URL}\"${Q/\ /+}\"" | grep -oP '\/url\?q=.+?&amp' | sed 's/\/url?q=//;s/&amp//'); echo -e "${stream//\%/\x}"
  182. #Search google.com on your terminal
  183.  
  184. curl -sd 'rid=value&submit=SUBMIT' <URL> > out.html
  185. #Submit data to a HTML form with POST method and save the response
  186.  
  187. albumart(){ local y="$@";awk '/View larger image/{gsub(/^.*largeImagePopup\(.|., .*$/,"");print;exit}' <(curl -s 'http://www.albumart.org/index.php?srchkey='${y// /+}'&itempage=1&newsearch=1&searchindex=Music');}
  188. #Find the cover image for an album
  189.  
  190. define(){ local y="$@";curl -sA"Opera" "http://www.google.com/search?q=define:${y// /+}"|grep -Eo '<li>[^<]+'|sed 's/^<li>//g'|nl|/usr/bin/perl -MHTML::Entities -pe 'decode_entities($_)';}
  191. #Define words and phrases with google.
  192.  
  193. weather(){ curl -s "http://api.wunderground.com/auto/wui/geo/ForecastXML/index.xml?query=${@:-<YOURZIPORLOCATION>}"|perl -ne '/<title>([^<]+)/&&printf "%s: ",$1;/<fcttext>([^<]+)/&&print $1,"\n"';}
  194. #Get the weather forecast for the next 24 to 48 for your location.
  195.  
  196. qrurl() { curl "http://chart.apis.google.com/chart?chs=150x150&cht=qr&chld=H%7C0&chl=$1" -o qr.$(date +%Y%m%d%H%M%S).png; }
  197. #Create QR codes from a URL.
  198.  
  199. curl -s "http://www.gravatar.com/avatar/`uuidgen | md5sum | awk '{print $1}'`?s=64&d=identicon&r=PG" | display
  200. #generate random identicon
  201.  
  202. while true;do n="$(curl -s http://news.yahoo.com/rss/|sed 's/</\n/g'|grep "title>"|sed -e '/^\// d' -e 's/title>/---------- /g' -e '1,3d'|tr '\n' ' ')";for i in $(eval echo {0..${#n}});do echo -ne "\e[s\e[0;0H${n:$i:$COLUMNS}\e[u";sleep .15;done;done &
  203. #Create A Continuous Yahoo! News Ticker For The Terminal
  204.  
  205. curlftpfs ftp://YourUsername:YourPassword@YourFTPServerURL /tmp/remote-website/ && rsync -av /tmp/remote-website/* /usr/local/data_latest && umount /tmp/remote-website
  206. #backup and synchronize entire remote folder locally (curlftpfs and rsync over FTP using FUSE FS)
  207.  
  208. watch -n 15 curl -s --connect-timeout 10 http://www.google.com/
  209. #Watch for when your web server returns
  210.  
  211. curl http://example.com/foo.tar.gz | tar zxvf -
  212. #Extract a remote tarball in the current directory without having to save it locally
  213.  
  214. curl -s http://bash.org/?random1|grep -oE "<p class=\"quote\">.*</p>.*</p>"|grep -oE "<p class=\"qt.*?</p>"|sed -e 's/<\/p>/\n/g' -e 's/<p class=\"qt\">//g' -e 's/<p class=\"qt\">//g'|perl -ne 'use HTML::Entities;print decode_entities($_),"\n"'|head -1
  215. #Random line from bash.org (funny IRC quotes)
  216.  
  217. curl -u <user>:<password> -d status="Amarok, now playing: $(dcop amarok default nowPlaying)" http://twitter.com/statuses/update.json
  218. #Twit Amarok "now playing" song
  219.  
  220. curl -n -d status='Hello from cli' https://twitter.com/statuses/update.xml
  221. #Update twitter from command line without reveal your password
  222.  
  223. curl -A Mozilla http://www.google.com/search?q=test |html2text -width 80
  224. #Search Google from the command line
  225.  
  226. curl http://www.phrack.org/archives/tgz/phrack[1-67].tar.gz -o phrack#1.tar.gz
  227. #Download all Phrack .tar.gzs
  228.  
  229. curl -s checkip.dyndns.org | grep -Eo '[0-9\.]+'
  230. #What is my ip?
  231.  
  232. tweet () { curl -u UserName -d status="$*" http://twitter.com/statuses/update.xml; }
  233. #another tweet function
  234.  
  235. curl -s search.twitter.com | awk -F'</?[^>]+>' '/\/intra\/trend\//{print $2}'
  236. #Print trending topics on Twitter
  237.  
  238. curl -sL xkcd.com | grep '<img [^>]*/><br/>' | sed -r 's|<img src="(.*)" title="(.*)" alt="(.*)" /><br/>|\1\t\2\t\3|' > /tmp/a; curl -s $(cat /tmp/a | cut -f1) | convert - -gravity south -draw "text 0,0 \"$(cat /tmp/a | cut -f2)\"" pdf:- > xkcd.pdf
  239. #Save xkcd to a pdf with captions
  240.  
  241. curl "http://www.commandlinefu.com/commands/matching/$(echo "$@" | sed 's/ /-/g')/$(echo -n $@ | base64)/plaintext"
  242. #Search commandlinefu.com from the command line using the API
  243.  
  244. eog `curl -s http://xkcd.com/ | sed -n 's/<h3>Image URL.*: \(.*\)<\/h3>/\1/p'`
  245. #View the newest xkcd comic.
  246.  
  247. curl -I -H "Accept-Encoding: gzip,deflate" http://example.org
  248. #Check if your webserver supports gzip compression with curl
  249.  
  250. cmdfu(){ local t=~/cmdfu;echo -e "\n# $1 {{{1">>$t;curl -s "commandlinefu.com/commands/matching/$1/`echo -n $1|base64`/plaintext"|sed '1,2d;s/^#.*/& {{{2/g'>$t;vim -u /dev/null -c "set ft=sh fdm=marker fdl=1 noswf" -M $t;rm $t; }
  251. #Search commandlinefu and view syntax-highlighted results in vim
  252.  
  253. curl -C - -o partially_downloaded_file 'www.example.com/path/to/the/file'
  254. #resume download using curl
  255.  
  256. u=`curl -d 'dl.start=Free' $(curl $1|perl -wpi -e 's/^.*"(http:\/\/rs.*)" method.*$/$1/'|egrep '^http'|head -n1)|grep "Level(3) \#2"|perl -wpi -e 's/^.*(http:\/\/rs[^\\\\]*).*$/$1/'`;sleep 60;wget $u
  257. #rapidshare download script in 200 characters
  258.  
  259. curl -v -k -u user:password "https://members.dyndns.org/nic/update?hostname=<your_domain_name_here>&myip=$(curl -s http://checkip.dyndns.org | sed 's/[a-zA-Z<>/ :]//g')&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"
  260. #Update dyndns.org with your external IP.
  261.  
  262. spellcheck(){ typeset y=$@;curl -sd "<spellrequest><text>$y</text></spellrequest>" https://www.google.com/tbproxy/spell|sed -n '/s="[0-9]"/{s/<[^>]*>/ /g;s/\t/ /g;s/ *\(.*\)/Suggestions: \1\n/g;p}'|tee >(grep -Eq '.*'||echo -e "OK");}
  263. #Google Spell Checker
  264.  
  265. detectlanguage(){ curl -s "http://ajax.googleapis.com/ajax/services/language/detect?v=1.0&q=$@" | sed 's/{"responseData": {"language":"\([^"]*\)".*/\1\n/'; }
  266. #Detect Language of a string
  267.  
  268. curl -s -d'&url=URL' http://goo.gl/api/url | sed -e 's/{"short_url":"//' -e 's/","added_to_history":false}/\n/'
  269. #Google URL shortener
  270.  
  271. expandurl() { curl -sIL $1 | grep ^Location; }
  272. #Expand shortened URLs
  273.  
  274. (cat ~/.bash_history;U='curl -s www.commandlinefu.com';$U/users/signin -c/tmp/.c -d'username=<USER>&password=<PASS>&submit=1'|$U/commands/favourites/json -b/tmp/.c|grep -Po 'nd":.*?[^\\]",'|sed -re 's/.*":"(.*)",/\1/g')>~/.h;HISTFILE=~/.h bash --login
  275. #run shell with your commandlinefu.com's favourites as bash_history
  276.  
  277. curl -O http://hosted.met-art.com/generated_gallery/full/061606AnnaUkrainePasha/met-art-free-sample-00[00-19].jpg
  278. #bulk dl files based on a pattern
  279.  
  280. curl -s -u user:password 'http://twitter.com/statuses/friends_timeline.xml?count=5' | xmlstarlet sel -t -m '//status' -v 'user/screen_name' -o ': ' -v 'text' -n
  281. #Get your Tweets from the command line
  282.  
  283. curl --form username=from_twitter --form password=from_twitter --form media=@/path/to/image --form-string "message=tweet" http://twitpic.com/api/uploadAndPost
  284. #Twitpic upload and Tweet
  285.  
  286. curl -u USER:PASS -d status="NEW STATUS" http://identi.ca/api/statuses/update.xml
  287. #Updating the status on identi.ca using curl.
  288.  
  289. curl -s "https://api.github.com/users/${USERNAME}/repos" | ruby -rubygems -e 'require "json"; JSON.load(STDIN.read).each {|repo| %x[git clone #{repo["ssh_url"]} ]}'
  290. #Clone all github repos of a user
  291.  
  292.  
  293.  
  294.  
  295.  
Add Comment
Please, Sign In to add comment