Neophyte awk question(s)
Geoff Kuenning
geoff at desint.UUCP
Tue Oct 9 12:25:05 AEST 1984
>> 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
More information about the Comp.unix
mailing list