tang@motcid.UUCP (Sam D. Tang) (04/12/91)
How does one add comments to an awk program? -----------------------------------------------------------------\ +---------- Sam Tang \| ####/ Motorola--Radio Telephone Systems Group/Cellular \ .. # Arlington Heights, IL < # (708) 632-2173, ...!uunet!motcid!tang _ | Not necessarily the opinions of my employer! \_/
bleck@motcid.UUCP (Robert R. Bleck) (04/12/91)
tang@motcid.UUCP (Sam D. Tang) writes: >How does one add comments to an awk program? A comment starts with the # character and finishes at the end of a line. Like: { print $1, $3 } # print first and third column Or: # This program prints the first and third column { print $1, $3 } -- Robert Bleck Motorola Inc. ..!uunet!motcid!bleck Cellular Infrastructure Division (708) 632-2329 1155 Dundee Road Arlington Heights, IL 60004
dfpedro@uswnvg.UUCP (Donn Pedro) (04/27/91)
In article <6188@flint4.UUCP>, tang@motcid.UUCP (Sam D. Tang) writes: > How does one add comments to an awk program? > Since an awk program is usually written in unix shell, I just comment outside of the actual awk script. like this: #gonna do some awk now. look out awk { awk like stuff } Look in the back of :'The AWK Progamming language' for examples. dfpedro@uswnvg.UUCP
icsu7039@attila.cs.montana.edu (Spannring) (04/29/91)
>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 ----------------------------------+--------------------------------
tchrist@convex.COM (Tom Christiansen) (04/30/91)
From the keyboard of icsu7039@attila.cs.montana.edu (Spannring): :Note that this is not a shell script. To run this program you will :have to type `awk -f count.awk' So how about starting it with: #!/bin/awk -f --tom