Skip to content

Instantly share code, notes, and snippets.

@serverwentdown
Created August 10, 2015 15:56
Show Gist options
  • Save serverwentdown/91dcdbb67f972f9d9935 to your computer and use it in GitHub Desktop.
Save serverwentdown/91dcdbb67f972f9d9935 to your computer and use it in GitHub Desktop.
Downloads the Wikipedia article and parses it for the first paragraph as a summary
#!/bin/zsh
SUMMARY=`curl -Ls "http://en.wikipedia.org/wiki/Special:Search?search=${*// /+}" | grep "<p>.*<\/p>" | head -n 1 | sed -e :a -e 's/<[^>]*>//g;/</N;//ba' | sed -E 's/\[[^>]{1,2}\]//g'`
echo -n $SUMMARY
if [ -n "$SUMMARY" ]; then echo; fi;
[ -n "$SUMMARY" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment