Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 Nov 2004 19:05:36 -0500 (EST)
From:      Chuck Robey <chuckr@chuckr.org>
To:        questions@freebsd.org
Cc:        Rod Person <personrp@hotpop.com>
Subject:   Re: Sed Help.....
Message-ID:  <20041110190348.Y25881@april.chuckr.org>
In-Reply-To: <20041111000034.C7304@maren.thelosingend.net>
References:  <200411101443.01977.personrp@hotpop.com> <20041111000034.C7304@maren.thelosingend.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 11 Nov 2004, Svein Halvor Halvorsen wrote:

>
> [Rod Person, 2004-11-10]
> >  Here is the relavent code:
> >
> >      KDMLINE="/usr/local/bin/kdm -nodaemon"
> >      REPLACELINE="/usr/X11R6/bin/xdm -nodaemon"
> >
> >      sed -e "s/$REPLACELINE/$KDMLINE/g" /etc/test/ttys > /etc/test/new
> >
> >  Here is the error I'm getting:
> >      sed: 1: "s//usr/X11R6/bin/xdm -n ...": bad flag in substitute command: 'X'
> >
>
>
> I was just made aware of a really nice feature of sed just yesterday:
>
> You can replace the / as a seperator with whatever character you want, as
> long as you use that same character all the way!!
>
> This is really nice, since you wouldn't need to escape the / characters as
> you otherwise would need to do.

Works this way with just about any system using the sed substitution
syntax (for instance, vi uses it, vim does).  Go looking at nearly any
large Gmake script (sucu as one of the makefiles from gcc) and you'll see
it all over the place.

>
> Just do like this (for instance):
>
> sed -2 s_$REPLACELINE_$KDMLIME_g /etc/test/ttys > /etc/test/new
> _______________________________________________
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"
>

----------------------------------------------------------------------------
Chuck Robey         | Interests include C & Java programming, FreeBSD,
chuckr@chuckr.org   | electronics, communications, and SF/Fantasy.

New Year's Resolution:  I will not sphroxify gullible people into looking up
fictitious words in the dictionary (on the wall at my old fraternity,
Signa Phi Nothing).
----------------------------------------------------------------------------



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20041110190348.Y25881>