Skip to content

Instantly share code, notes, and snippets.

@giulioungaretti
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save giulioungaretti/50cc26320bed0b6b63cc to your computer and use it in GitHub Desktop.
Save giulioungaretti/50cc26320bed0b6b63cc to your computer and use it in GitHub Desktop.
sort
gzcat 2015-02-01.json.log.gz | jq -c '[.timestamp, .]' >> json.log && sort -t "," -k1 json.log | cut -d "," -f 2- | cut -d "]" -f 1 >> clean.json
@tudborg
Copy link

tudborg commented Apr 17, 2015

gzcat 2015-02-01.json.log.gz |
    >( echo -n $(jq -c -r  '.timestamp') && jq -c -y '.' ) > json.log &&
    sort -t " " -k1 json.log | cut -d " " -f 2- > clean.json

@tudborg
Copy link

tudborg commented Apr 17, 2015

#!/bin/bash
INFILE="data.jsonline"
OUTFILE="sorted.jsonline"
while read line; do
    ts="$(echo "$line" | jq -r '.t')"
    echo "$ts $line"
done < <(cat "$INFILE") | sort -k1 - | cut -d " " -f 2- > "$OUTFILE"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment