Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 11721

Select column header if column contains specific string

$
0
0

I have a large tab-delimited file in which each column is a patient and each row shows the genotype for a specific position, where missing data is denoted by ./.I want to extract the column headers of columns that contain missing genotypes at any of the positions.

Example:

Variant  P_1  P_2  P_3var_1    0/0  ./.  1/0var_2    ./.  ./.  0/0var_3    1/0  ./.  1/0

Expected output

P_1P_2

I tried -unsuccessfully:

code=$(                  awk '{for (i=1; i<=NF; i++)        if ($i == "./.") {printf NR==1, sep "\n"}    }' file) &&   awk "{print $code}" file

Would be happy for any suggestions!


Viewing all articles
Browse latest Browse all 11721

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>