From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=0.0 required=3.0 tests=BAYES_20,MSGID_SHORT autolearn=no autolearn_force=no version=3.4.5-pre1 Date: 9 Jul 93 15:14:08 GMT From: mcsun!ub4b!alcbel!btmpj6!devjwu@uunet.uu.net (Wuyts Jan) Subject: Re: Seek LOC Count Software in Pub Domain Message-ID: <2082@alcbel.be> List-Id: Here is a simple awk program that gives you some information about LOCode and LOComments. It looks for -- in the input and everthing not behind a -- is considered a LOCode --------------next is first line-------------- BEGIN { comment_line=0; total_comment=0; lines_with_comment=0; total_lines_with_comment=0; blank_comment=0; total_blank_comment=0; blank_line=0; total_blank=0; old_NR=1; current_file=FILENAME; print "File\t\t\t\tComment_lines\tBlank_lines\tCode_lines\tTot al\n"; } FILENAME != current_file { printf("%-26.26s\t%d\t(%d)\t%d\t\t%d\t(%d)\t%d\n", current_fi le, comment_line, blank_comment, blank_line, NR+1-old_NR-comment_line-blank_lin e,lines_with_comment-comment_line,NR+1-old_NR); current_file=FILENAME; total_comment=total_comment+comment_line; comment_line=0; total_lines_with_comment=total_lines_with_comment+lines _with_comment; lines_with_comment=0; total_blank=total_blank+blank_line; blank_line=0; total_blank_comment=total_blank_comment+blank_comment; blank_comment=0; old_NR=NR; } /^[ ]*--/ { comment_line++; } /[ ]*--/ { lines_with_comment++; } /^[ ]*--[ ]*$/ { blank_comment++; } /^[ ]*$/ { blank_line++; } END { printf("%-26.26s\t%d\t(%d)\t%d\t\t%d\t(%d)\t%d\n", current_fi le, comment_line, blank_comment, blank_line, NR+1-old_NR-comment_line-blank_lin e,lines_with_comment-comment_line,NR+1-old_NR); total_comment=total_comment+comment_line; total_lines_with_comment=total_lines_with_comment+lines_with_ comment; total_blank=total_blank+blank_line; total_blank_comment=total_blank_comment+blank_comment; printf("\nGrand total\t\t\t%d\t(%d)\t%d\t\t%d\t(%d)\t%d\n", t otal_comment, total_blank_comment, total_blank, NR-total_comment-total_blank, t otal_lines_with_comment-total_comment,NR); } --------------previous is last line-------------- Put this in a file, say count.awk Count the lines with: awk -f count.awk *.a It gives per file a line indicating filename, #comment_lines (#empty comments), #blank_lines, #code_lines (#comment ed_code_lines). It also gives you a grand total. Hope this is of any help Jan Wuyts