Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10 beta 3/9/83; site desint.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!mhuxj!ihnp4!zehntel!hplabs!sdcrdcf!trwrb!desint!geoff
From: geoff@desint.UUCP (Geoff Kuenning)
Newsgroups: net.unix
Subject: Re: Neophyte awk question(s)
Message-ID: <146@desint.UUCP>
Date: Mon, 8-Oct-84 22:25:05 EDT
Article-I.D.: desint.146
Posted: Mon Oct  8 22:25:05 1984
Date-Received: Wed, 10-Oct-84 04:45:12 EDT
References: <487@loral.UUCP>, <4363@utzoo.UUCP>
Organization: his home computer, Thousand Oaks, CA
Lines: 32

>> I needed an awk process to output an SOH character (binary 1).  When
>> I put the following in:
>> 
>> 	{printf"%c",'\001'}
>> 
>> awk complained and stubbornly refused.  However, the exact same
>> thing in C (given the syntactical difference with parentheses)
>> works fine.  I understood that the 'printf' statement in awk
>> was the same as in C.  At any rate, I can't seem to get an SOH from
>> awk.

>Awk is not C, despite surface similarities and occasional rash
>statements in the manual.  There are no single characters in awk,
>just strings, so the single quotes are a no-no and the %c format
>is meaningless.  More serious, alas, is that awk takes "\001" as
>a string four characters long, so there isn't any good answer to your
>problem.

Gee, on system V I just tried:

    awk '{printf ("%c", 7);}'


and got a bell for every line I typed, just like you would expect.  "%c"
prints an integer as a character;  awk just passes the format and the integer
to C's printf.  Note the correct syntax in the example above;  "printf" in
awk *does* require parentheses--it's "print" that doesn't, just to keep life
confusing.
-- 
	Geoff Kuenning
	First Systems Corporation
	...!ihnp4!trwrb!desint!geoff