awk comments

Spannring icsu7039 at attila.cs.montana.edu
Tue Apr 30 01:27:13 AEST 1991


>In article <6188 at flint4.UUCP>, tang at motcid.UUCP (Sam D. Tang) writes:
> How does one add comments to an awk program?

You use the pound sign (#) for a comment.  The comment will stretch 
to the end of the line.  Here is an example-


>---------------cut here-------------<
# count.awk
# This awk script will count the number of words, and lines in a file.
# a word is defined as any string of characters delimited by white space
{
	# We will do the next line for every record in the file
	words += NF;
}
END {
	printf "words: %5d\n", words; # print number of words in field width of 5
	printf "lines: %5d\n", NR;    # print number of lines using width of 5
}
>---------------cut here-------------<

Note that this is not a shell script.  To run this program you will 
have to type `awk -f count.awk'

--
====================================================================
 Six of one, 110 (base 2) of       | Craig Spannring
 another.                          | icsu7039 at caesar.cs.montana.edu
 ----------------------------------+--------------------------------



More information about the Comp.unix.programmer mailing list