Created
May 27, 2014 17:19
-
-
Save rev087/0dec723e009957432ff6 to your computer and use it in GitHub Desktop.
Command-line reddit search via jq
This file contains 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
# Search reddit for a string | |
redsearch() { | |
curl "http://www.reddit.com/search.json?q=$1" | jq '[.data.children[].data | {created_utc, permalink, num_comments, ups, author, subreddit, url, title} | select(.title | contains("'$1'"))] | sort_by(.created_utc)' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
I have this function in my ~/.profile, and use it in the Terminal as
redsearch something
. Output is pretty-printed, syntax-highlighted JSON, ordered by date. Can be piped to other tools or jq again for further filtering/ordering.Result