title: How to count lines in a file on hdfs command?
body: <p>I have a file on HDFS that I want to know how many lines are. (testfile)</p>
  
  <p>In linux, I can do: </p>
  
  <pre><code>wc -l &lt;filename&gt;
  </code></pre>
  
  <p>Can I do something similar with "hadoop fs" command? I can print file contents with:</p>
  
  <pre><code>hadoop fs -text /user/mklein/testfile
  </code></pre>
  
  <p>How do I know how many lines do I have? I want to avoid copying the file to local filesystem then running the wc command.</p>
  
  <p>Note: My file is compressed using snappy compression, which is why I have to use -text instead of -cat</p>