I have a file the contains
apple
apple
banana
orange
apple
orange
I want a script that finds the duplicates apple and orange and tells the user that the following : apple and orange are repeated. I tried
nawk '!x[$1]++' FS="," filename
to find repeated item so how can i print them out in unix bash ?
In order to print the duplicate lines, you can say:
$ sort filename | uniq -d
apple
orange
If you want to print the count as well, supply the -c option to uniq:
$ sort filename | uniq -dc
      3 apple
      2 orange
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With