please help, I want to group together all linked data pairs.
If I have 10 pairs, each row showing col2 and col3 are linked.
Then I am looking to make
The first col value can be chosen from any of the linked row labels, I have used the first one here.
Here is my try
If I have 10 pairs, each row showing col2 and col3 are linked.
Code:
R1 1 2
R2 1 3
R3 2 4
R4 3 4
R5 5 6
R6 8 1
R7 6 7
R8 9 10
Code:
R1 1 2 3 4 8
R5 5 6 7
R8 9 10
The first col value can be chosen from any of the linked row labels, I have used the first one here.
Here is my try
Code:
awk 'NR==FNR{a[$2]=$3 ; a[$3]=$2;next} $2" "$3 in a { print $1,a[$2" "$3]}' file file