home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!uknet!siesoft!wstuart!stuart
- From: stuart@wstuart (Stuart Hood)
- Newsgroups: comp.unix.shell
- Subject: Re: Sed with shell variables
- Message-ID: <1992Aug21.110719.11512@siesoft.co.uk>
- Date: 21 Aug 92 11:07:19 GMT
- References: <2701@nlsun1.oracle.nl>
- Sender: news@siesoft.co.uk (Usenet News)
- Reply-To: stuart@siesoft.co.uk
- Organization: Siemens Nixdorf Information Systems Ltd.
- Lines: 25
- X-Newsreader: Tin 1.1 PL4
-
- rgasch@nl.oracle.com (Robert Gasch) writes:
- : Using sed to edit strings is usually a nice and practical
- : method of doing so. I you want to change a pattern you usually
- : say:
- : echo $something|sed 's/pattern1/pattern2/'
- :
- : The problem I ran into is that I can't get shell variables to
- : work as arguments. When I type
- : echo $something|sed 's/$this_pattern_var/$that_pattern_var/'
- :
- : sed throws up on me. I've tried various combinations of quotation
- : marks without success. Is there an easy way of doing this??
- :
-
- echo "$something" | sed 's/'"$this_pattern_var"'/'"$that_pattern_var"'/'
-
- The double quotes around the shell variables are only
- needed if they contain any spaces (or tabs).
-
- Stuart.
- -
- --
- S I E M E N S Stuart Hood === Siemens Nixdorf House, Bracknell, Berks, UK
- ------------- Phone: + 44-344-850892 Email: stuart@siesoft.co.uk
- N I X D O R F - Never let ignorance stand in the way of a good argument -
-