title: How to efficiently list files that have exactly `n` lines?
body: <p>In order to list files that have exactly <code>n</code> lines, one can do</p>
  
  <pre><code>n=5
  find . -name "*.txt" | xargs wc -l | awk -v n=${n} -F" " '{if ($1==n) {print $2} }'
  </code></pre>
  
  <p>but this solution is quite slow as it counts the number of lines for each file first and then only select those that have <code>n</code> lines. A process that would count the lines and stops when it reaches <code>n+1</code> lines would be much more efficient (esp. when dealing with big files that have plenty of lines).</p>
  
  <p><strong>How to efficiently list files that have exactly <code>n</code> lines?</strong></p>
  
  <p>Note, for the special case, where each line is of exactly the same size, then one could probably do</p>
  
  <pre><code>n=5
  sizePerLine=500
  find . -name '*.txt' -size $(( ${n} * ${sizePerLine} ))
  </code></pre>