Skip to content

Instantly share code, notes, and snippets.

@andrewbattista
Created September 8, 2020 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewbattista/af73512ce47f46933964b68ca688d7fa to your computer and use it in GitHub Desktop.
Save andrewbattista/af73512ce47f46933964b68ca688d7fa to your computer and use it in GitHub Desktop.
Concatenate many JSON files into single JSON file with JS

If you have a directory path with many JSON files in it and you want them all on a single document for batch edits use JS

find . -name '*.json' -exec cat '{}' + | jq -s '.' > /Users/staff/Desktop/newjsonsinglefile.json

To reduce the process time for exceedingly large examples, you may be able to simply use

find . -name '*.json' -exec jq -s '{}' + > /Users/staff/Desktop/newjsonsinglefile.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment