Skip to main content
grammar
Source Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 264

Deleting duplicates with awk is pretty common and simple. But I need to print only those lines that are duplicated ,whenwhen we compare only one column. I tried this command :

awk 'seen[$2]++'

but as uyou can see it has flaws. It prints duplicates, but only since their 22nd appearance. I've only started getting used to unix and bash, so it would be great with besides answer uif you could explain athe solution to me.

Deleting duplicates with awk is pretty common and simple. But I need to print only those lines that are duplicated ,when we compare only one column. I tried this command :

awk 'seen[$2]++'

but as u can see it has flaws. It prints duplicates, but only since their 2 appearance. I've only started getting used to unix and bash, so would be great with besides answer u could explain a solution to me.

Deleting duplicates with awk is pretty common and simple. But I need to print only those lines that are duplicated when we compare only one column. I tried this command :

awk 'seen[$2]++'

but as you can see it has flaws. It prints duplicates, but only since their 2nd appearance. I've only started getting used to unix and bash, so it would be great if you could explain the solution to me.

Source Link
ogarogar
  • 191
  • 1
  • 6

Using awk to write only duplicates

Deleting duplicates with awk is pretty common and simple. But I need to print only those lines that are duplicated ,when we compare only one column. I tried this command :

awk 'seen[$2]++'

but as u can see it has flaws. It prints duplicates, but only since their 2 appearance. I've only started getting used to unix and bash, so would be great with besides answer u could explain a solution to me.