Xref: utzoo comp.unix.questions:18822 comp.unix.wizards:20027 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!zaphod.mps.ohio-state.edu!mips!smsc.sony.com!dce From: dce@smsc.sony.com (David Elliott) Newsgroups: comp.unix.questions,comp.unix.wizards Subject: Re: AWK/shell quoting (was: Re: Access to UNIX-Related Publications) Message-ID: <1990Jan6.233340.9978@smsc.sony.com> Date: 6 Jan 90 23:33:40 GMT References: <487@longway.TIC.COM> <166@omaha1.UUCP> <18067@umn-cs.CS.UMN.EDU> Reply-To: dce@Sony.COM (David Elliott) Organization: Sony Microsystems Corp. Lines: 32 In article <18067@umn-cs.CS.UMN.EDU> 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. ... >2. You can do it by cooperating with shell quoting. This is hairy, >but will print a single quote: > > awk 'BEGIN {print "'"'"'"}' Hopefully, people tend towards this solution. Some people I have worked with like to put awk scripts in separate files. To me, that's like breaking up your C program into separate binaries and exec'ing them as needed - it slows down the program and makes it harder to maintain. One trick I use is to say awk 'BEGIN { Sq = "'"'"'"; and then use Sq wherever I need single quotes. Also, if you have an awk that handles octal escapes in sprintf, you could use that to put a single quote into Sq. -- David Elliott dce@smsc.sony.com | ...!{uunet,mips}!sonyusa!dce (408)944-4073 "But Pee Wee... I don't wanna be the baby!"