AWK/shell quoting (was: Re: Access to UNIX-Related Publications)

Joe Hamlin hamlin at blackbird.afit.af.mil
Mon Jan 8 13:45:17 AEST 1990


mike at umn-cs.CS.UMN.EDU (Mike Haertel) writes:

>In article <166 at omaha1.UUCP> wcc at omaha1.UUCP (William C Carey) writes:
>>Any of the luminaries out there know how to get 'awk' (not nawk) to ouput a
>>single-quote character ( ascii 0x27 ).  I can't get the 'print' or
>>the 'printf' statement to do it with any combination of backslashes,
>>double-quotes, or percent characters.

>1.  You can move the awk program to a file, foo.awk, and then merely
>say "awk -f foo.awk" in the shell program.  Then an awk program
>	BEGIN {print "'"}

>2.  You can do it by cooperating with shell quoting.  This is hairy,
>	awk 'BEGIN {print "'"'"'"}'

Here's a couple more:

awk 'BEGIN {printf "%c\n", 39}'

or if you need to output the quote in several places, you might
want to try:

awk 'BEGIN {Q = sprintf("%c",39)} {print Q "Don" Q "t quote me on this." Q}'
-- 
Joe Hamlin    <hamlin at blackbird.afit.af.mil>



More information about the Comp.unix.questions mailing list