请参阅在线Json的更改日志

时间:2013-11-29 10:44:04

标签: json bash wget tail

我有一个json online(6,5m),有近10,000个地理位置。我正在寻找能够检查变化的东西。每天增加近60个点。

我发现了这个:tail -f equivalent for an URL

但是当我尝试使用给定的命令时,我的debian上有bash错误。

最后我想格式化它们并将它们发送到irc频道。

1 个答案:

答案 0 :(得分:0)

我会在本地保护JSON文件并对其进行区分。

#!/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