Entering edit mode
7.0 years ago
viv3kanand
▴
10
Hi, I have this table,
ID ref1 ref2
a 1 3
b 3 1
c 5 1
d 2 4
Tab seperated and there are n number of IDs (a,b,c,..) and references (ref1,ref2,... and so on). I want to replace the numbers with its corresponding ID if greater than 2, so the desired output will be like,
ref1 ref2
b a
c d
I have manged to do for single columns with awk
awk -F "\t" '{if($2>2) print $1}' filename
and
awk 'BEGIN{OFS=FS="\t"}$2>2{$2=$1}{print}' filename
But I can't use them for larger files.
Any help is much appreciated, Thank you.
Vivek