I need to do an exact
match followed by a partial
match and retrieve the strings from two columns. I would ideally like to do this with awk
.
Input:
k141_18046_1 k141_18046_1
k141_18046_1 k141_18046_2
k141_18046_2 k141_18046_1
k141_12033_1 k141_18046_2
k141_12033_1 k141_12033_1
k141_12033_2 k141_12033_2
k141_2012_1 k141_2012_1
k141_2012_1 k141_2012_2
k141_2012_2 k141_2012_1
k141_21_1 k141_2012_2
k141_21_1 k141_21_1
k141_21_2 k141_21_2
Expected output:
k141_18046_1 k141_18046_2
k141_18046_2 k141_18046_1
k141_2012_1 k141_2012_2
k141_2012_2 k141_2012_1
In both columns, the first part of the ID is the same. I need to get the IDs where either ID_1 && ID_2 (OR) ID_2 && ID_1 are present in a single row.
Thank you, Susheel