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

'hasOwnProperty' in javascript -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -

How to understand 2 main() functions after using uftrace to profile the C++ program? -