Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!ucdavis!iris!tuck From: tuck@iris.ucdavis.edu (Devon Tuck) Newsgroups: comp.unix.xenix Subject: How do I print a single quote in AWK? Keywords: awk Message-ID: <6955@ucdavis.ucdavis.edu> Date: 7 Mar 90 23:58:16 GMT Sender: uucp@ucdavis.ucdavis.edu Reply-To: tuck@iris.ucdavis.edu (Devon Tuck) Organization: U.C. Davis - Department of Electrical Engineering and Computer Science Lines: 35 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@ucdavis.edu)