Last active
December 30, 2015 21:39
-
-
Save danreeves/7888969 to your computer and use it in GitHub Desktop.
What Is Status Code ... ? Grabs the name of the status code you enter from Wikipedia. e.g:
````
--> wisc 404
404 Not Found
````
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
if [[ $1 == '' ]]; then | |
print 'Please pass in a status code, e.g. 404' | |
exit 2 | |
fi | |
A='/\>(' | |
B='[^\<]*?)\</ and print $1' | |
REGEX=$A$1$B | |
MATCH=`curl -s http://en.wikipedia.org/wiki/List_of_HTTP_status_codes | perl -l -ne $REGEX` | |
if [[ $MATCH == '' ]]; then | |
print "Nothing matched '$1'" | |
else | |
FIRST=("${(f)MATCH}") | |
print $FIRST[1] | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment