title: Count number of lines after wrapped by terminal’s length
body: <p>Suppose your <code>tput cols</code> (or <code>COLUMNS</code>) is equal to <code>100</code> and you have a plain text file <code>foo.txt</code> with a single line that is 120 characters long.</p>
  
  <p>If you wanted to count number of lines it contains you could do <code>cat foo.txt | wc -l</code> and unsurprisingly enough the output would presumably be <code>1</code>.</p>
  
  <p>But if you’d open the file with a pager, such as <code>less</code>, like <code>less foo.txt</code> then what your eyes would actually see are two lines instead (AFAIK, unless you don’t say <code>--chop-long-lines</code>, <code>less</code> will “wrap" lines that are longer than your terminal’s width).</p>
  
  <p>Again, if you’d try to see line numbers, using <code>less</code>, like <code>less --LINE-NUMBERS foo.txt</code>, than the output would be something like:</p>
  
  <pre><code>1 something something...
  1 more stuff
  </code></pre>
  
  <p>Basically <code>less</code> is “aware” that the only line in <code>foo.txt</code> is longer than your terminal’s width, so it will “wrap” it to visualize, but will tell you that actually first and the second lines that you see are actually the same line #1 in <code>foo.txt</code>.</p>
  
  <p>So, my question is: how could you “calculate” (say, in bash) number of lines <em>after</em> wrapping (number of lines that your eyes see), rather than number of lines that the file actually contains? (In scenario above, the number would be <code>2</code> instead of <code>1</code>.)</p>