If I have a folder with the following file names:
cluster_sizes_0.txt
cluster_sizes_1.txt
cluster_size_2.txt
etc.
Each file contains a single column of values.
Is there a command within linux such that I could combine all files into cluster_all.txt?
The first column in this new file would correspond to cluster_sizes_0.txt
, the second column would be cluster_sizes_1.txt
etc.
There could be as many as 200 cluster txt files, but it changes for each folder. I am looking for a way to combine these files, instead of copying each one by one.
Also, I need to make sure they are pasted into the file in order. This may have some issues with the numbering system, since I only include single digits if below 10.
For instance:
paste cluster_size.* > cluster_all.txt
doesn't paste them in order due to the numbering. How can I fix the numbering without manually changing all of them?
zsh
, you could use its numeric glob qualifierpaste -d, cluster_sizes_*.txt(n) > cluster_all.txt
– steeldriver Jul 28 '18 at 17:33