Date: Sun, 3 Jul 2005 16:33:19 -0300 From: Alejandro Pulver <alejandro@varnet.biz> To: fbsd_user@a1poweruser.com Cc: freebsd-questions@FreeBSD.ORG Subject: Re: help with sh script Message-ID: <20050703163319.58bd970c@phobos.mars.bsd> In-Reply-To: <MIEPLLIBMLEEABPDBIEGKEBMHIAA.fbsd_user@a1poweruser.com> References: <20050703172255.GA5805@slackbox.xs4all.nl> <MIEPLLIBMLEEABPDBIEGKEBMHIAA.fbsd_user@a1poweruser.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 3 Jul 2005 14:59:32 -0400 "fbsd_user" <fbsd_user@a1poweruser.com> wrote: > > > std_text='No ALTQ support in kernel ALTQ related functions disabled' > ret_ob='No ALTQ support in kernel ALTQ related functions disabled > OK' > > ret_ob=`printf "$ret_ob" | sed 's/\$std_text//g'` > Does not strip off the std_text stuff. > > How would I code a statement to remove everything from $ret_ob > but the ok at the end so $ret_ob would only contain the ok?? > > Some times $ret_ob will end in some error message and that is > what I want to capture after striping off the std_text. > > > Thanks > Hello, The problem here is that single quotes ("'") avoid variable substitution. e.g. var="text" echo $var # outputs text echo '$var' # outputs $var (literally) Also the backslash avoids variable substitution when placed before a "$". e.g. echo $var # outputs text echo \$var # outputs $var (literally) The solution is this: ret_ob=`printf "$ret_ob" | sed "s/$std_text//g"` ^ ^ ^ Hope that helps. Best Regards, Ale
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050703163319.58bd970c>