Recursive cat all the files into single file Recursive cat all the files into single file linux linux

Recursive cat all the files into single file


find data/ -name '*.json' -exec cat {} \; > uber.json

a short explanation:

find <where> \  -name <file_name_pattern> \  -exec <run_cmd_on_every_hit> {} \; \    > <where_to_store>


Use find to get all the JSON files and concatenate them.

find data -name '*.json' -exec cat {} + > all.json

Note that this will not be valid JSON. If you want a JSON file to contain multiple objects, they need to be in a containing array or object, so you'd need to add [ ] around them and put , between each one.


Alternatively -- if you have a list of your files -- you can pipe that to xargs

<path to your files> | xargs cat > all.json