I have one large text table, tab separated. The first row is a header. I then have a second text file that contains a subset of the headers in the first file. I want to extract all the columns of the first file whose header is contained in the list given in the second file. Here an example of the inputs and the desired output:

`DATA.TXT`

```
head0 head1 head2 head3 head4
1 25 1364 22 13
2 10 215 1 22
```

`LIST.TXT`

```
head0  
head4
```

Desired output:

```
head0 head4  
1 13  
2 22
```
Just with a simple google search a hundred of questions/answers related to this topic can be easily found, specially, in **stackoverflow**: http://unix.stackexchange.com/questions/114829/display-column-that-has-a-specific-string

I'd suggest you to try to solve this kind of problems searching on internet and trying yourself before asking. In this case, you can get what you want with a little modification to the solution proposed on the link:

    awk -F'\t' 'NR==FNR{arr[$1]++;next}{for(i=1; i<=NF; i++) if ($i in arr){a[i]++;}} { for (i in a) printf "%s\t", $i; printf "\n"}' file2 file1