How do I print a single quote in AWK?

Devon Tuck tuck at iris.ucdavis.edu
Thu Mar 8 09:58:16 AEST 1990


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 :-(

##########################################################################
# Description: AWK program to change 
#
#|$ADD C.NAME
#
# to ...
#
#|C$ADD C.NAME                                                          HM
#|      INCLUDE 'NAME.h'                                                X      
#
# Note: the '|' is the beginning of a line of code in Fortran 77 and the
# letters to the right of the screen exist as flags in the 'safe' 73-80
# columns of a traditional fortran program.
##########################################################################
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

Thanks for your help,
	Devon (tuck at ucdavis.edu)



More information about the Comp.unix.xenix mailing list