Created
May 24, 2017 21:29
-
-
Save arlina-espinoza/f691385d9ff0f2d17da6af33a6505b5d to your computer and use it in GitHub Desktop.
Bash script to split a JSON into multiple files. Uses jq.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Split a JSON into multiple files. Uses jq. | |
# Usage | |
# ./split_json.sh /path/to/json/file | |
file="$1" | |
jq -cr 'keys[] as $k | "\($k)\t\(.[$k])"' "$file" | awk -F\\t '{ file=$1".json"; print $2 > file; close(file); }' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment