I have bunch of files sitting in folders like
data\A\A\A\json1.json data\A\A\A\json2.json data\A\A\B\json1.json ... data\Z\Z\Z\json_x.json
I want to cat all the jsons into one single file?
You can use the * character to match all the files in your current directory. cat * will display the content of all the files.
To join two or more text files on the Linux command-line, you can use the cat command. The cat (short for “concatenate”) command is one of the most commonly used commands in Linux as well as other UNIX-like operating systems, used to concatenate files and print on the standard output.
Replace file1 , file2 , and file3 with the names of the files you wish to combine, in the order you want them to appear in the combined document. Replace newfile with a name for your newly combined single file.
Appending content to an existing file To append content after you merge multiple files in Linux to another file, use double redirection operator. (>>) along with cat command. Rather than overwriting the contents of the file, this command appends the content at the end of the 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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With