In a parent folder I have multiple folders inside it. Within each folder I have text file "text.txt". The text files are similar in all the folders, each text file contain 100 line and one column of numbers. example
cat /folder1/text1.txt
1654
1684
535
35131
.
.
I want to merge all these text files as columns in one file using the command paste
. In the parent folder I ran the command
paste ./*/text*.text > all_text.txt # the content for all_text.txt is as follow:
cat all_text.txt
1654 354531 ....
1684 224
535 2424
35131 24
.
.
.
How can I add the folders names as a header for each pasted column to get the following output
cat all_text.txt
folder#1 folder #2 .....
1654 354531
1684 224
535 2424
35131 24
.
.
.