home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / unix / question / 14696 < prev    next >
Encoding:
Internet Message Format  |  1992-12-15  |  1.7 KB

  1. Xref: sparky comp.unix.questions:14696 comp.unix.shell:5070
  2. Path: sparky!uunet!spool.mu.edu!uwm.edu!cs.utexas.edu!asuvax!ukma!cs.widener.edu!dsinc!phent!kkress
  3. From: kkress@phent.UUCP (Kenneth R. Kress)
  4. Newsgroups: comp.unix.questions,comp.unix.shell
  5. Distribution: world
  6. Subject: Re: Substituting with sed, ...
  7. Keywords: sed m4 substitutions quoting strings
  8. Message-ID: <9212144482@phent.UUCP>
  9. Organization: That's Entertainment BBS
  10. Date: Mon, 14 Dec 92 23:58:10 EST
  11. Lines: 51
  12.  
  13. I wrote:
  14. > Howdy neighbor,
  15. >     That is one cruel and inhuman torturous problem. I like to solve
  16. > things first, no matter how crude the solution, and then tidy up, but this
  17. > was so ugly, I'll offer it in the hopes that someone else will show both of
  18. > us a "nice" solution using sed.   Here goes.
  19. > test.sed data2 produces:
  20. >     acaY csacacYcascsc  
  21. >     "cscaXcacsXcs"  csaYc "X" caY
  22. >     Yaca Ycaca  ca "caXcas"  ccaY cacs
  23. > cat test.sed produces:
  24. > sed 's/X/ X /g'     |
  25. > sed 's/\"/`/'        |
  26. > sed 's/\"/~/'        |
  27. > sed 's/\"/`/'        |
  28. > sed 's/\"/~/'        |
  29. > sed 's/\"/`/'        |
  30. > sed 's/\"/~/'        |
  31. > sed 's/\"/`/'        |
  32. > sed 's/\"/~/'        |
  33. > sed    's/`/``/g
  34. >     s/~/~~/g'    |
  35. > tr "~" "'" > $$tmp
  36. > m4 test.m4 $$tmp    > $$tmpa
  37. > sed    's/ X /X/g
  38. >     s/ Y /Y/g
  39. >     s/`/\"/g' $$tmpa |
  40. > sed "s/\'/\"/g"
  41. > # clean exit
  42. > rm $$tm*
  43. > exit 0
  44.  
  45.     Oops! I forgot to define test.m4
  46.  
  47. cat test.m4 produces:
  48. define(`X', `Y')
  49.  
  50. > Let it's hideousness inspire others to respond.
  51. >                 Ken.
  52. ===================================================================
  53. Ken Kress, Glenside, PA * dsinc!phent!kkress 
  54.     Daring ideas are like chessmen moved forward;
  55.     they may be beaten, but they may start a winning game.
  56.                     Johann Wolfgang von Goethe
  57. -------------------------------------------------------------------
  58.