Xref: utzoo comp.unix.questions:18817 comp.unix.wizards:20023 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uwvax!umn-d-ub!umn-cs!mike From: mike@umn-cs.CS.UMN.EDU (Mike Haertel) Newsgroups: comp.unix.questions,comp.unix.wizards Subject: AWK/shell quoting (was: Re: Access to UNIX-Related Publications) Message-ID: <18067@umn-cs.CS.UMN.EDU> Date: 6 Jan 90 17:56:40 GMT References: <487@longway.TIC.COM> <166@omaha1.UUCP> Reply-To: mike@umn-cs.cs.umn.edu (Mike Haertel) Organization: Free Software Foundation Lines: 31 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. Your problem is that you are embedding the awk program in a quoted shell string, and the single quotes you are trying to use in the awk program are interacting with the shell's quoting conventions. There are 2 solutions: 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 to print a single quote would look like: BEGIN {print "'"} 2. You can do it by cooperating with shell quoting. This is hairy, but will print a single quote: awk 'BEGIN {print "'"'"'"}' Breaking it down we see that the argument to awk consists of three concatenated shell-quoted strings: 'BEGIN {print "' "'" '"}' -- Mike Haertel "Of course, we have to keep in mind that this year's Killer Micro is next year's Lawn Sprinkler Controller . . ." -- Eugene Brooks