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 -->
  #6 (permalink)  
Old 05-24-2007
kthatch kthatch is offline
Registered User
 

Join Date: Mar 2007
Posts: 21
I tried each of these suggestions and neither worked.

Results:

#egrep -cv '#|^$' active_servers
this displayed the total but on screen only, not in the file

#awk '!/^#/ && !/^$/{c++}END{print c}' active_servers
same as above

#awk '!/^[ \t]*(#|$)/ {c++; ct++} /#/ && c { printf "%s\n\n\n%s", c, $0; c=0} END { print ct}' active_servers
awk: syntax error near line 1
awk: bailing out near line 1

To provide more detail, I have a script that produces the output above (in my original post) to a file - less the totals that I am seeking help with. When I refer to comments, I mean lines that are preceded with ## and the sections are separated with a blank line as a result of this "sed '/this/{x;p;x;}'" in my script.

Thanks again! More suggestions would be welcome!
Reply With Quote