Search code examples
jsonbashwgettail

See change log of online Json


I have a json online (6,5m) with nearly 10.000 geographic point. I'm looking for something to check changes. Nearly 60 points are added every day.

I found this : tail -f equivalent for an URL

But I have bash error on my debian when I try to using the command given.

At the end I would like to format them and send them to an irc channel.


Solution

  • I would safe the JSON file locally and diff it.

    #!/bin/sh
    
    # filename for current version of JSON file
    d=$(date +"%Y%m%d-%H%M%S")
    current=data-$d.json # => data-20131129-123856.json
    
    # download current version of JSON file
    wget --quiet -O $current http://www.lhorn.de/~lutz/so/data.json
    
    # determine the previous version of the JSON file (the second to last)
    previous=$(find . -name "data-*.json" | sort | tail -2 | head -1)
    
    # diff the previous and the current version of the JSON file
    diff -u $previous $current