home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!sun-barr!olivea!spool.mu.edu!umn.edu!noc.msc.net!news.stolaf.edu!news.stolaf.edu!guenther
- From: guenther@StOlaf.edu (Philip Guenther)
- Newsgroups: comp.unix.shell
- Subject: Re: seding with variables and /s question
- Message-ID: <GUENTHER.92Sep12181519@lars.StOlaf.edu>
- Date: 13 Sep 92 01:15:19 GMT
- References: <lb4q5tINNaef@jethro.Corp.Sun.COM>
- Sender: news@news.stolaf.edu
- Organization: St. Olaf College, Northfield, MN USA
- Lines: 31
- In-Reply-To: tmhoff@oogoody.Corp.Sun.COM's message of 12 Sep 1992 22:01:33 GMT
-
- In article <lb4q5tINNaef@jethro.Corp.Sun.COM> tmhoff@oogoody.Corp.Sun.COM (Todd Hoff) writes:
-
- > I'm having a hard time using variables to specify search patterns
- > containind /s in sed. Say my home development directory path is in
- > $DEVEL and my destination path is in $DEST. Since these are path
- > specifications they contain /s and when I do something like: sed -e
- > 's/$DEVEL/$DEST/' $file > $destfile sed barfs on the /s. I've tried
- > lots of variations. Any clues?
-
- > Thanx
-
- A quick check of the sed(1) man page shows...
-
- (2)s/regular expression/replacement/flags [...]
- Any character may be used instead of `/'.
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
- Also, neither csh nor sh do variable substitution within single
- quotes, so you would want to enter:
-
- sed -e "s:$DEVEL:$DEST:" $file > $destfile
-
- In fact, as ":" isn't a special character, you needn't do any quoting.
- Now if $DEVEL or $DEST contained special characters/whitespace...
-
- Philip Guenther
- --
- guenther@stolaf.edu (Philip Guenther) | The ACC might agree with me,
- Student Sys Prog, Academic Computing Center | but with that bunch, (and me)
- St Olaf College, Northfield, MN 55057-1001 | you never know... :-) :-| :-(
- "Life makes sense? LIFE MAKES SENSE!!? Where do people get these ideas?"-me
-