Access to UNIX-Related Publications

William C Carey wcc at omaha1.UUCP
Sat Jan 6 01:52:21 AEST 1990


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.  I am trying to get a pipe line
into SQL which calls for single quotes in it's string searches.

I am currently using 'tr' in the next 'section-of-pipe' after awk to
translate some character (ie `, backtick) into a single-quote as in:

cat nofind | awk '

/^3\`/	{
	print char
	split($0,line,"`")
	n = split(line[2],array,"-")
	if ( n = 4){
		printf("select * from ranges where\n")
		printf("addr_county = `%s*` and \n", array[1])
		printf("addr_locality = `%s*` and \n", array[2])
		printf("addr_st_name = `%s*` and \n", array[3])
		printf("addr_thorough = `%s*` /\n", array[4])
	}
}
' | tr '`' '\047' | SQL

This works but is not "awkward" enough( sorry about the pun).



More information about the Comp.unix.questions mailing list