title: Find and KEEP all DUPLICATE lines (instead of unique lines) in a text file
body: <p>I am aiming to <strong>identify and keep DUPLICATE, TRIPLICATE, etc.</strong> lines, i.e., all lines that <strong>occur more than once</strong> in Notepad++? In other words, how can I delete all unique lines only?</p>
  
  <p>For example, here are seven (7) separate lists and the desired true duplicate lines of each lists (shown as 7 columns, regard each column as an individual list or file!).  (The lists here are shown side by side <strong>only to save space</strong>, in real life, each of the 7 lists occurs alone and independently from the others and are separate files!)</p>
  
  <pre><code>list1  list2  list3  list4  list5  list6  list7
  1      0      0      0      0      0      0
  2      1      1      1      1      1      1
  3      2      2      2      2      2      2
  4      3      3      3      3      3      3
  4      4      4      4      4      4      4
  4      4      4      4      4      4      4
  5      4      4      4      4      4      4
  6      5      5      5      5      5      5
  7      5      5      5      5      5      5
  8      6      6      6      6      6      6
  9      6      6      6      6      6      6
  abc    7      7      7      7      7      7
  abd    8      8      8      8      8      8
  abd    9      9      9      9      9      9
  abe           &lt;CR&gt;   9      9      9      9
                              &lt;CR&gt;   99     99
                                            &lt;CR&gt;
  
  [Lines of multiple occurence of above lists:]         
  4      4      4      4      4      4      4
  4      4      4      4      4      4      4
  4      4      4      4      4      4      4
  abd    5      5      5      5      5      5
  abd    5      5      5      5      5      5
         6      6      6      6      6      6
         6      6      6      6      6      6
                       9      9      9      9
                       9      9      9      9
  </code></pre>
  
  <p>There are many solutions to <strong>eliminate</strong> duplicates (e.g., TextFX; <a href="https://stackoverflow.com/questions/29303148">notepad++ delete duplicate and original lines to keep unique lines</a>), I can not find solutions to <strong>keep</strong> duplicates only.</p>
  
  <p><code>((.*)\R(\2\R)+)*\K.+\R</code>
  @Lars Fischer: This script works nearly OK, except the last entry of the (presorted) list needs to be unique line followed by a <code>&lt;CR&gt;</code> empty line. One (suboptimal) workaround is to insert an artificial (helper) unique line (e.g., zzz) followed by an empty line <code>&lt;CR&gt;</code> as the last two lines.</p>
  
  <p>(END OF QUESTION)</p>
  
  <hr>
  
  <p>UPDATE 3: This question is reposted per stackoverflow "<a href="https://stackoverflow.com/questions/46699485/find-and-keep-all-duplicate-lines-in-notepad-delete-all-unique-lines">ask a new question</a>" instruction. (<a href="https://stackoverflow.com/users/546871/adrianhhh">@AdrianHHH</a>, <a href="https://stackoverflow.com/users/7450125/b-desai">@B. Desai</a>, <a href="https://stackoverflow.com/users/1685157/paolo-forgia">@Paolo Forgia</a>, <a href="https://stackoverflow.com/users/2670892/greg-449">@greg-449</a>, <a href="https://stackoverflow.com/users/7296893/erik-von-asmuth">@Erik von Asmuth</a> draw the incorrect conclusion that this question is a duplicate of <a href="https://stackoverflow.com/questions/29303148/notepad-delete-duplicate-and-original-lines-to-keep-unique-lines">notepad++ delete duplicate and original lines to keep unique lines</a>. This question is definitely not a duplicate of the one <a href="https://stackoverflow.com/users/546871/adrianhhh">@AdrianHHH</a> et al quotes. <a href="https://i.stack.imgur.com/Zus3O.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/Zus3O.jpg" alt="History."></a> </p>
  
  <p>UPDATE 2: <a href="https://stackoverflow.com/users/546871/adrianhhh">@AdrianHHH</a> This question is not less "broad" (in fact, one can hardly be more specific) or less researched than other Notepad++ questions, including the one <a href="https://stackoverflow.com/questions/29303148/notepad-delete-duplicate-and-original-lines-to-keep-unique-lines">https://stackoverflow.com/questions/29303148</a> cited (wrongly) by <a href="https://stackoverflow.com/users/546871/adrianhhh">@AdrianHHH</a> et al. as the same question.</p>
  
  <p>UPDATE:
  <a href="https://stackoverflow.com/users/546871/adrianhhh">@AdrianHHH</a>, <a href="https://stackoverflow.com/users/7450125/b-desai">@B. Desai</a>, <a href="https://stackoverflow.com/users/1685157/paolo-forgia">@Paolo Forgia</a>, <a href="https://stackoverflow.com/users/2670892/greg-449">@greg-449</a>, <a href="https://stackoverflow.com/users/7296893/erik-von-asmuth">@Erik von Asmuth</a>
  <strong>This questions is different from:</strong>
  <a href="https://stackoverflow.com/questions/29303148/notepad-delete-duplicate-and-original-lines-to-keep-unique-lines">https://stackoverflow.com/questions/29303148</a>
  beacuse Q <a href="https://stackoverflow.com/questions/29303148/notepad-delete-duplicate-and-original-lines-to-keep-unique-lines">29303148</a> is <strong>(i)</strong> neither asking how to identify and keep only the lines of multiple occurrence, <strong>(ii)</strong> neither there is a solution provided in the answers for that. Q <a href="https://stackoverflow.com/questions/29303148/notepad-delete-duplicate-and-original-lines-to-keep-unique-lines">29303148</a> asks "...I just need the unique lines."</p>