Skip to content

Instantly share code, notes, and snippets.

@jmakeig
Last active March 23, 2023 15:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmakeig/6eb3df63002a3f26505ff8ff1f29f309 to your computer and use it in GitHub Desktop.
Save jmakeig/6eb3df63002a3f26505ff8ff1f29f309 to your computer and use it in GitHub Desktop.
Split a file containing a JSON Array into one file per item
#!/usr/bin/env bash
# Splits a file that contains a top-level JSON Array
# into individual files, one per item, named sequentially
# https://stedolan.github.io/jq/download/
jq -c .[] "$1" | awk '{print > (NR ".json")}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment