I would like to make a loop in which a certain column (in my case column 4) from a text file is added as last column to a new text file. I have in total around 500 text files (V1-V500) from which I want to take the fourth column and add it to the new text file (columns separated by tabs). All text files have the same number of lines. In addition, the heading of the column that was added should contain the file name of the text file where it was originally from. I've tried to work out a command line with awk and a for-loop already, but none of my commands work. I've tried command lines based on the command line of a previous post. I'm working in Linux with GNU tools available.
To give an example: V1 text file
header1 header2 header3 header4
1 5 9 13
2 6 10 14
3 7 11 15
4 8 12 16
V2 text file:
header1 header2 header3 header4
17 25 21 29
18 26 22 30
19 27 23 31
20 28 24 32
NEW text file:
V1 V2
13 29
14 30
15 31
16 32
Thanks for your help!