How do I print a single quote in AWK?
Steven M. List
itkin at mrspoc.Transact.COM
Fri Mar 9 10:11:47 AEST 1990
tuck at iris.ucdavis.edu (Devon Tuck) writes:
>Here is a question for those of you out there who are familiar with 'awk':
>I am having difficulties getting a single quote (') printed. I have tried
>using the printf, and print commands, as well as the sprintf() built-in.
>The following is an example program which works, but does not print the
>single quotes. Intuitively, I would think that line 3 could be:
> printf "%-72sX\n"," INCLUDE '"(name = substr($0, 8, 6))".h'"
>and that should do the trick -- but it doesn't :-(
>awk '/\$ADD C\./ {
> printf "%-72sHM\n","C"$1" "$2;
> printf "%-72sX\n"," INCLUDE "(name = substr($0, 8, 6))".h"
> }
> {
> # If there was no change, print out the line.
> print
>}' awktest
Do you suppose that the awk script is being included on the command
line with SINGLE QUOTES might affect what is being attempted? Perhaps
if the script were either written to a temporary file first or if the
single quotes inside the awk script were escaped (preceded with back-
slashes) this script would work properly. It's not AWK's problem, it's
the shell's (and the programmer's).
--
+----------------------------------------------------------------------------+
: Steven List @ Transact Software, Inc. :^>~ :
: Chairman, Unify User Group of Northern California :
: {apple,coherent,limbo,mips,pyramid,ubvax}!itkin at guinan.Transact.COM :
More information about the Comp.unix.xenix
mailing list