Skip to content

Instantly share code, notes, and snippets.

@canabady
Last active November 20, 2018 04:33
Show Gist options
  • Save canabady/9650d8c604b5a93cb779534352660c20 to your computer and use it in GitHub Desktop.
Save canabady/9650d8c604b5a93cb779534352660c20 to your computer and use it in GitHub Desktop.
To filter id and title from json file and output to html for ebook creation
# Select id and title from JSON File based on TEXT_TO_SEARCH and append it to OUTPUT.html
$ for f in $(find $PWD -name "JSON_FILE.json"); do idTitleTextArray=($(cat $f | jq -r -c '.categories[].articles[] | select(.title | contains("TEXT_TO_SEARCH"))|"\(.id).html\">\(.title)</a>"'|sort)); if [ ${#idTitleTextArray[@]} -gt 0 ];then echo "<a href=\"${f%/*}/web/html/${idTitleTextArray[@]}" >> OUTPUT.html; fi; done;
# Create MOBI ebook from HTML
$ ebook-convert OUTPUT.html OUTPUT.mobi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment