wcc@omaha1.UUCP (William C Carey) (01/05/90)
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).
matthew@sunpix.UUCP ( Sun Visualization Products) (01/08/90)
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 > Here's an example that should get you in the right direction: awk 'BEGIN { SQ = sprintf("%c", 39); DQ = sprintf("%c", 34); } { printf("%cHow is this?%c\n", DQ, DQ); printf("%cAnd this?%c\n", SQ, SQ); } -- Matthew Lee Stier | Sun Microsystems --- RTP, NC 27709-3447 | "Wisconsin Escapee" uucp: sun!mstier or mcnc!rti!sunpix!matthew | phone: (919) 469-8300 fax: (919) 460-8355 |
bzs@world.std.com (Barry Shein) (01/10/90)
>Any of the luminaries out there know how to get 'awk' (not nawk) to ouput a >single-quote character ( ascii 0x27 ). sq = sprintf("%c",39) print sq -- -Barry Shein Software Tool & Die, Purveyors to the Trade | bzs@world.std.com 1330 Beacon St, Brookline, MA 02146, (617) 739-0202 | {xylogics,uunet}world!bzs