Xref: utzoo comp.unix.questions:18847 comp.unix.wizards:20044 Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!tut.cis.ohio-state.edu!ucsd!helios.ee.lbl.gov!ncis.tis.llnl.gov!blackbird!hamlin From: hamlin@blackbird.afit.af.mil (Joe Hamlin) Newsgroups: comp.unix.questions,comp.unix.wizards Subject: Re: AWK/shell quoting (was: Re: Access to UNIX-Related Publications) Message-ID: <1456@blackbird.afit.af.mil> Date: 8 Jan 90 02:45:17 GMT References: <487@longway.TIC.COM> <166@omaha1.UUCP> <18067@umn-cs.CS.UMN.EDU> Organization: Air Force Institute of Technology; WPAFB, OH Lines: 25 mike@umn-cs.CS.UMN.EDU (Mike Haertel) writes: >In article <166@omaha1.UUCP> wcc@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