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 UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 05-23-2007
reborg's Avatar
reborg reborg is offline
Administrator
 

Join Date: Mar 2005
Location: Ireland
Posts: 3,824
Quote:
Originally Posted by ghostdog74
Code:
awk '!/^#/ && !/^$/{c++}END{print c}' "file"
to extend that somewhat(untested):

Code:
awk '!/^[ \t]*(#|$)/ {c++; ct++} /#/ && c { printf "%s\n\n\n%s", c, $0; c=0} END { print ct}' file

Last edited by reborg; 05-23-2007 at 05:17 PM..
Reply With Quote