I have folder (data) contain large number of text files. Each text file contain one column of numbers, the column contain 30 numbers. I want to create table that combine the columns in these text files. I used the following command:
cd data
paste *.txt > all_data.txt
The output is as follows:
0.834679 0.612341 0.510057 0.580128 .....
1.837894 1.061547 0.961449 1.343096 .....
1.638215 1.024628 1.113596 1.80506 .....
1.596119 0.971842 1.14204 1.73881 .....
1.568142 1.025716 1.217219 1.769668 .....
1.554016 0.977165 1.226769 1.786335 .....
1.543137 1.001812 1.247598 1.840443 .....
1.491823 0.99437 1.28337 1.784271 .....
1.371208 0.931998 1.259749 1.717408 .....
1.390867 0.905996 1.300722 1.739213 .....
1.35813 0.283377 1.307122 1.733058 .....
......
This command combined all the columns in one big spreadsheet. My question: is there any way to paste each column in the text files and make the text file name header to that column. As follows:
text_file1 text_file2 text_file3 text_file4 ....
0.834679 0.612341 0.510057 0.580128 .....
1.837894 1.061547 0.961449 1.343096 .....
1.638215 1.024628 1.113596 1.80506 .....
1.596119 0.971842 1.14204 1.73881 .....
1.568142 1.025716 1.217219 1.769668 .....
1.554016 0.977165 1.226769 1.786335 .....
1.543137 1.001812 1.247598 1.840443 .....
1.491823 0.99437 1.28337 1.784271 .....
1.371208 0.931998 1.259749 1.717408 .....
1.390867 0.905996 1.300722 1.739213 .....
1.35813 0.283377 1.307122 1.733058 .....
......