If I have a file something like:
223 898 teeth
223 899 mouth
223 900 r9
445 800 round
My question is how can I use awk command to substitute column 2 with column 3, only for the row in which column 3 starts letter ‘r’?
For substitution I can use gsub but I am not able get only to that row whose column three starts with ‘r’.
I also tried using grep for finding word starting with r using :
grep "r*" filename | awk '{gsub($2,$3); print;}'
But this command substitutes column 2 to all the columns of that row.