home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.unix.questions:14696 comp.unix.shell:5070
- Path: sparky!uunet!spool.mu.edu!uwm.edu!cs.utexas.edu!asuvax!ukma!cs.widener.edu!dsinc!phent!kkress
- From: kkress@phent.UUCP (Kenneth R. Kress)
- Newsgroups: comp.unix.questions,comp.unix.shell
- Distribution: world
- Subject: Re: Substituting with sed, ...
- Keywords: sed m4 substitutions quoting strings
- Message-ID: <9212144482@phent.UUCP>
- Organization: That's Entertainment BBS
- Date: Mon, 14 Dec 92 23:58:10 EST
- Lines: 51
-
- I wrote:
- > Howdy neighbor,
- > That is one cruel and inhuman torturous problem. I like to solve
- > things first, no matter how crude the solution, and then tidy up, but this
- > was so ugly, I'll offer it in the hopes that someone else will show both of
- > us a "nice" solution using sed. Here goes.
- >
- > test.sed data2 produces:
- >
- > acaY csacacYcascsc
- > "cscaXcacsXcs" csaYc "X" caY
- > Yaca Ycaca ca "caXcas" ccaY cacs
- >
- > cat test.sed produces:
- > sed 's/X/ X /g' |
- > sed 's/\"/`/' |
- > sed 's/\"/~/' |
- > sed 's/\"/`/' |
- > sed 's/\"/~/' |
- > sed 's/\"/`/' |
- > sed 's/\"/~/' |
- > sed 's/\"/`/' |
- > sed 's/\"/~/' |
- > sed 's/`/``/g
- > s/~/~~/g' |
- > tr "~" "'" > $$tmp
- > m4 test.m4 $$tmp > $$tmpa
- > sed 's/ X /X/g
- > s/ Y /Y/g
- > s/`/\"/g' $$tmpa |
- > sed "s/\'/\"/g"
- > # clean exit
- > rm $$tm*
- > exit 0
-
- Oops! I forgot to define test.m4
-
- cat test.m4 produces:
- define(`X', `Y')
-
- >
- > Let it's hideousness inspire others to respond.
- >
- > Ken.
- >
- ===================================================================
- Ken Kress, Glenside, PA * dsinc!phent!kkress
- Daring ideas are like chessmen moved forward;
- they may be beaten, but they may start a winning game.
- Johann Wolfgang von Goethe
- -------------------------------------------------------------------
-