Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!dali.cs.montana.edu!attila.cs.montana.edu!icsu7039 From: icsu7039@attila.cs.montana.edu (Spannring) Newsgroups: comp.unix.programmer Subject: Re: awk comments Keywords: awk Message-ID: <3896@dali> Date: 29 Apr 91 15:27:13 GMT References: <6188@flint4.UUCP> <751@uswnvg.UUCP> Sender: usenet@dali.cs.montana.edu Distribution: comp Organization: Montana State University, Dept. of Computer Science, Bozeman MT 59717 Lines: 29 >In article <6188@flint4.UUCP>, tang@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@caesar.cs.montana.edu ----------------------------------+--------------------------------