Skip to content

Instantly share code, notes, and snippets.

@leonidlm
Created July 31, 2014 13:37
Show Gist options
  • Save leonidlm/02633b872844a79e973c to your computer and use it in GitHub Desktop.
Save leonidlm/02633b872844a79e973c to your computer and use it in GitHub Desktop.
Concatenate json files by date (which appears as part of the file name)
#
# grouping files of 2014-04-12-01.json format into one json per mday (2014-04-12)
#
distinct_dates=$(ls -l | awk '{print $9}' | awk -F "-" '{count[$1"-"$2"-"$3]++}END{for(j in count) print j}')
for i in $distinct_dates
do
echo "Grouping for $i month"
cat $i-*.json* > /tmp/$i.json
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment