Hello,

I have a matrix in which I am trying to retrieve specific rows from it and save it in text

An example matrix is

```
Affy ID       DDM1       DGKI2      FDGYYY1     GUHIL6
1438_at       0.0635     0.2065     -0.2112     0.0856
1487_at       0.071      -0.1315    0.0263      0.0198
1494_f_at     0.0045     -0.0237    0.0156      -0.1352
1598_g_at     -0.0541    0.0006     -0.1369     -0.0589
160020_at     -0.0925    0.2182     -0.1967     -0.0074
1729_at       -0.0017    -0.2209    -0.086      -0.0709
1773_at       -0.0273    -0.0181    0.1042      0.0136
177_at        -0.0276    -0.2563    0.3975      -0.0535
179_at        -0.0472    0.0979     -0.216      -0.2814
1861_at        0.0121    -0.4038    0.0016      0.0334
200000_s_at   -0.1021    -0.0887    -0.0452     0.0035
```

Lets say the name of this matrix is `M.txt` and the selected rows is in a list named `mSelected.txt` (consisting of `1438_at`, `1729_at` and `200000_s_at`). My output should look like the following file

```
Affy ID       DDM1       DGKI2      FDGYYY1     GUHIL6
1438_at       0.0635     0.2065     -0.2112     0.0856
1729_at       -0.0017    -0.2209    -0.086      -0.0709
200000_s_at   -0.1021    -0.0887    -0.0452     0.0035
```

Is there also anyway to convert their Affy ID to Gene name?

```
$ head /Users/Desktop/mSelected.txt | cat -vet
1438_at^M1729_at^M200000_s_at 

$ head /Users/Desktop/m.txt | cat -vet
Affy ID                             ^I DDM1               ^IDGKI2                ^IFDGYYY1       ^I GUHIL6^M1438_at^I0.0635^I0.2065^I-0.2112^I0.0856^M1487_at^I0.071^I-0.1315^I0.0263^I0.0198^M1494_f_at^I0.0045^I-0.0237^I0.0156^I-0.1352^M1598_g_at^I-0.0541^I0.0006^I-0.1369^I-0.0589^M160020_at^I-0.0925^I0.2182^I-0.1967^I-0.0074^M1729_at^I-0.0017^I-0.2209^I-0.086^I-0.0709^M1773_at^I-0.0273^I-0.0181^I0.1042^I0.0136^M177_at^I-0.0276^I-0.2563^I0.3975^I-0.0535^M179_at^I-0.0472^I0.0979^I-0.216^I-0.2814^M1861_at^I0.0121^I-0.4038^I0.0016^I0.0334^M200000_s_at^I-0.1021^I-0.0887^I-0.0452^I0.0035
```
    awk 'FNR==NR{a[$0];next}($1 in a)' mSelected.txt M.txt

If the files are huge, join could be the fastest way:

     join -t "<TAB>*" -1 1 -2 1 -o 1.1,1.2,1.3,1.4,1.5 <(sort -k1,1 M.txt) <(sort -k1,1 mSelected.txt) > output

*literal tab = ctrl-v-tab