What is the best, python or bash for selectively concatenating lots of files?
- by Werner
Hi,
I have around 20000 files coming from the output of some program, and their names follow the format:
data1.txt
data2.txt
...
data99.txt
data100.txt
...
data999.txt
data1000.txt
...
data20000.txt
I would like to write a script that gets as input argument the number N. Then it makes blocks of N concatenated files, so if N=5, it would make the following new files:
data_new_1.txt: it would contain (concatenated) data1.txt to data5.txt (like cat data1.txt data2.txt ... data_new_1.txt )
data_new_2.txt: it would contain (concatenated) data6.txt to data10.txt
.....
I wonder what do you think would be the best approach to do this, whether bash, python or another one like awk, perl, etc.
The best approach I mean in terms of simplest code.
Thanks