-
-
Save rokibhasansagar/a8ec012edb306a3b3f441a0132c31412 to your computer and use it in GitHub Desktop.
Bash script to split a JSON into multiple files. Uses jq.
This file contains 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