title: Print the duplicate lines in a file using awk
body: <p>I have a requirement to print all the duplicated lines in a file where in <code>uniq -D</code> option did not support. So I am thinking of an alternative way to print the duplicate lines using awk. I know that, we have an option in awk like below.</p>
  
  <p>testfile.txt</p>
  
  <pre><code>apple
  apple
  orange
  orange
  cherry
  cherry
  kiwi
  strawberry
  strawberry
  papaya
  cashew
  cashew
  pista
  </code></pre>
  
  <p>The command:</p>
  
  <pre><code>awk 'seen[$0]++' testfile.txt
  </code></pre>
  
  <p>But the above does print only the unique duplicate lines. I need the same output that <code>uniq -D</code> command retrieves like this.</p>
  
  <pre><code>apple
  apple
  orange
  orange
  cherry
  cherry
  strawberry
  strawberry
  cashew
  cashew
  </code></pre>