Link Details

UNIX doesn't have any real command which helps us to get the number of lines which has records or data in it. But what UNIX offers is to get the number of new lines.

Posted by RafaelZin  |   Nov 05 2012 / 07:45

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Comments

User 411746 avatar

nikolas.lotz replied ago:

#> cat TEXTFILE | grep -v '^[[:blank:]]*$' | wc -l

Reply 0 votes
User 965185 avatar

RafaelZin replied ago:

Hi Nikolas, Your command would escape the empty lines, but it will fail in the below scenario: 1.Make a file with 2 records one on each line Example: name.dat Rafael (press Enter) Zin (dont press Enter) 2. After the data in 2nd line dont press enter. As discussed above. 3. Now run your command you will get wrong output.

Reply 0 votes
User 411746 avatar

nikolas.lotz replied ago:

Nope. After fixing all the typos in your script ('gerp' vs 'grep' and a few missing backticks) it returns the same result.

Reply 0 votes
User 411746 avatar

nikolas.lotz replied ago:

And another typo: "$nl_coun2" vs "$nl_count2"

Reply 0 votes

Recommended Links

Upvoters (4)



Downvoters (1)



Scala
Written by: Ryan Knight
Featured Refcardz: Top Refcardz:
  1. Apache Hadoop
  2. Play
  3. Akka
  4. Debugging JavaScript
  5. Design Patterns
  1. Apache Hadoop
  2. REST
  3. Java
  4. Git
  5. Java Performance
Connect with DZone