Created
February 2, 2021 05:37
-
-
Save samerickson/cf95e77c505f963531da40bc9f32ecfb to your computer and use it in GitHub Desktop.
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
# This file allows you to combine multiple json files into one | |
# Just pass all the paths to all the files you want to combine using | |
# command line arguments | |
FILES=$@ | |
TMP_FILE="/tmp/results.tmp" | |
RESULT_FILE=results.json | |
echo "${FILES}" | |
echo "[" > "${TMP_FILE}" | |
for FILE in "${FILES}"; do | |
SET="$(cat ${FILE} | sed 's/^/ /g')" | |
# ISSUE: should not add trailing comma on last entry | |
printf "${SET},\n" | sed 's/}{/},\n {/g' >> "${TMP_FILE}" | |
done | |
echo "]" >> "${TMP_FILE}" | |
sed 'x;${s/,$//;p;x;};1d' ${TMP_FILE} > "${RESULT_FILE}" | |
rm /tmp/results.tmp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment