The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 05-23-2007
kthatch kthatch is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 28
How to count lines - ignoring blank lines and commented lines

What is the command to count lines in a files, but ignore blank lines and commented lines?

I have a file with 4 sections in it, and I want each section to be counted, not including the blank lines and comments... and then totalled at the end.

Here is an example of what I would like my output to look like:

##comment##
line1
line2
line3
line4
line5
line6

6 lines

##comment##
line7
line8
line9
line10
line11
line12
line13
line14
line15
line16
line17

11 lines

##comment##
line18
line19
line20
line21
line22

5 lines

##comment##
line23
line24
line25
line26
line27
line28
line29
line30
line31
line32
line33
line34
line35

13 lines

35 total lines

Thank you in advance, for your help!