unix - Replace repeating variables by "NA" using awk -
suppose have next file:
1 blue 2 red 3 yellow 4 yellow 5 yellow 6 purple 7 purple 8 green
and following file, replacing repeated variables "na"
1 blue 2 red 3 yellow 4 na 5 na 6 purple 7 na 8 green
try -
$ awk 'a[$2]++{$2="na"} 1' f 1 blue 2 red 3 yellow 4 na 5 na 6 purple 7 na 8 green
Comments
Post a Comment