Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Nov 2004 00:04:17 +0100 (CET)
From:      Svein Halvor Halvorsen <svein-freebsd-questions@theloosingend.net>
To:        Rod Person <personrp@hotpop.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Sed Help.....
Message-ID:  <20041111000034.C7304@maren.thelosingend.net>
In-Reply-To: <200411101443.01977.personrp@hotpop.com>
References:  <200411101443.01977.personrp@hotpop.com>

next in thread | previous in thread | raw e-mail | index | archive | help

[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.

Just do like this (for instance):

sed -2 s_$REPLACELINE_$KDMLIME_g /etc/test/ttys > /etc/test/new



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