{S/E/D/HELP}
Is there a SED wizard in the audience?
This sed searches through some text and successively finds instances of the keyword "conditions" and prints the closest instance of what ever follows after "subreddit_id":
sed -n '/conditions/{s/.*,"subreddit_id":"\([^"]*\)".*/\1/;p;}' /home/a/Desktop/subredditidsearch.txt
The contents of the data set "subredditidsearch.txt":
{"ups":1,"created_utc":"1204329608","subreddit":"reddit.com","link_id":"t3_69ta9","author_flair_text":null,"score":1,"subreddit_id":"t5_6","body":"What conditions would have to be met in order for the U.S. led invasion of Iraq to be considered a genocide?","name":"t1_c03bgax","distinguished":null,"edited":false,"parent_id":"t1_c03bg9s","archived":true,"author_flair_css_class":null,"gilded":0,"retrieved_on":1425832318,"id":"c03bgax","controversiality":0,"downs":0,"author":"bsiviglia9","score_hidden":false}
{"edited":false,"parent_id":"t1_c03bc4g","distinguished":null,"name":"t1_c03bgay","body":"You missed his their/they're mixup.","score":1,"subreddit_id":"t5_6","author_flair_text":null,"link_id":"t3_6aezn","ups":1,"subreddit":"reddit.com","created_utc":"1204329608","score_hidden":false,"author":"Cyrius","downs":0,"controversiality":0,"id":"c03bgay","retrieved_on":1425832318,"author_flair_css_class":null,"gilded":0,"archived":true}
Now, if I change "subreddit_id" to say "author", it will print the correct author, in this case "Cyrius".
Is there an easy way to modify this sed to print both "subreddit_id" and "author" when it finds the keyword? Any help would be greatly appreaciated!