jq

<< Back to wiki homepage

Table of contents:

Regexp match and time conversion example

Used exported twitter data:

cat tweets.json| jq '.[] | if (.tweet.created_at | strptime("%a %b %d %H:%M:%S %z %Y"))[0] > 2015 and select(.tweet.full_text|test(".*SEARCHEDTEXT.*")) then .tweet.id else empty end'

An example tweet on the dataset (to understand better):

{
  "tweet": {
    "retweeted": false,
    "source": "<a href=\"http://twitter.com\" rel=\"nofollow\">Twitter Web Client</a>",
    "entities": {
      "hashtags": [],
      "symbols": [],
      "user_mentions": [],
      "urls": []
    },
    "display_text_range": [
      "0",
      "66"
    ],
    "favorite_count": "2",
    "id_str": "588799141939179521",
    "truncated": false,
    "retweet_count": "0",
    "id": "588799141939179521",
    "created_at": "Thu Apr 16 20:20:29 +0000 2015",
    "favorited": false,
    "full_text": "Some random useless tweet",
    "lang": "tr"
  }
}