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

Popular posts from this blog

javascript - Knockout pushing observable and computed data to an observable array -

'hasOwnProperty' in javascript -

Trouble making a JSON string -