Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site wgivax.UUCP Path: utzoo!watmath!clyde!burl!ulysses!gamma!epsilon!zeta!sabre!petrus!bellcore!decvax!mcnc!unccvax!wgivax!mo From: mo@wgivax.UUCP Newsgroups: net.unix Subject: Re: Quoting quotes in awk Message-ID: <152@wgivax.UUCP> Date: Wed, 5-Mar-86 08:28:26 EST Article-I.D.: wgivax.152 Posted: Wed Mar 5 08:28:26 1986 Date-Received: Fri, 7-Mar-86 07:50:30 EST References: <1074@turtlevax.UUCP> Lines: 36 >From ken@turtlevax.UUCP (Ken Turkowski) Sun Feb 6 01:28:16 206 >How does one quote quotes in awk? I'd like to do something like the following: > print doit "\"" last0 "\"", "\"" $0 "\"" | "sh" >Alternatively, I'd like to execute the program "doit" with arguments >determined from the awk program: > print "" | doit "\"" last0 "\"", "\"" $0 "\"" execute 'awk -f ' where file has following awk commands: BEGIN {Q = "\""} NR > 1 {printf("doit %s %s %s %s %s %s | sh\n",Q,last,Q,Q,$0,Q)} NR > 1 {printf("%s%s | doit %s %s %s %s %s %s\n",Q,Q,Q,last,Q,Q,$0,Q)} {last = $0} note that this could also be done directly in sh, and, depending on exactly what you are trying to do, you might be able to save some steps in getting the command generated by "doit" to execute. following is an example of how to do it in sh: lastline="" read line while (test $line) do if(test $lastline) then echo 'doit " '$lastline' " " '$line' " | sh' fi lastline=$line read line done note that this script expects input to be given to it