[Solved] Filtering and replacing from multiple columns


This one should work:

awk 'BEGIN{ OFS = "\t" }NR==1{ for ( i = 1; i <= NF; i++) if ( $i ~"Pval" ) a[i]; print $0}NR>1{for ( i in a ) if ( $i > 0.5 ) $i = "NA"; print $0 }' file

Output:

Rv_FC    Rv_Pval  Gc_FC  Gc_Pval  
2        0.001     3      NA
3        NA        1      0.0002
3        0.0001    2      NA

7

solved Filtering and replacing from multiple columns