Hi I have a matrix with n rows and m columns like below example. i want to extract all the pairs with values <200.
Input
A B C D
A 100 206 51 300
B 206 100 72 48
C 351 22 100 198
D 13 989 150 100
Output format
A,A:200
A,C:51
B,B:100
B,C:72
..........
D,D:100
pamu
2
Please post relevant information always. It will be very helpful
Try
awk 'NR==1{split($0,A)}
NR>1{for(i=2;i<=NF;i++){if($i<200){print $1","A[i-1]":"$i}}}' file
Regards,
pamu
1 Like