On Fri, 26 Jan 2001 at 8:34am (-0800), Brad Doster wrote:

> >> Ahhh.. we need another \ - one to protect $ from sed and
> >> another to protect the first \ from the backticks.
>
> >>    varlist=`echo "$varlist" | sed 's/\\$//g'`
>
> Apparently that's still not enough.  I think '\\$' parses to '\$' in which
> looks like it should be used to look for a literal '$', but apparently
> not -- maybe it's looking for '\<endofline>'?
>
> Dave's solution of 's/\\\\$//g' does work.  I think '\\\\$' is parsing to
> '\\$' and then that to '\$' -- it looks the same, but definitely acts
> differently.  Maybe we need extra protection for both the '\' and the '$'?
>
> And I thought this was going to be an easy question! :)
>

Err... dunno. It works for me...

$ varlist='$var1 $var2 $var3'
$ echo $varlist
$var1 $var2 $var3
$ varlist=`echo "$varlist" | sed 's/\\$//g'`
$ echo $varlist
var1 var2 var3
$

Are you using a " instead of a ' maybe? It changes the way the shell treats
/'s (and other meta-chars).  's/\\\\$//g' (in single quotes) won't work for
the same reason.. you wind up with too many \'s instead of not enough.  By
the time the sed command see it we need it to look like s/\$//g - i'll use
some echos instead of sed so we can see what's going on.

$ echo `echo "s/\\\\$//g"`      # double quotes, 4 escapes, good.
s/\$//g
$ echo `echo 's/\\\\$//g'`      # single quotes, 4 escapes, bad.
s/\\$//g
$ echo `echo "s/\\$//g"`        # double quotes, 2 escapes, bad.
s/$//g
$ echo `echo 's/\\$//g'`        # single quotes, 2 escapes, good.
s/\$//g
$

If we use double quotes we need to protect each escape from the shell that's
acutally doing the calling.

That's making the big assumption that wrong sort of quotes is your problem.
If not then umm.. err.. *shurg* ... Did i meantion in worked for me? ;)

M.

-- 
WebCentral Pty Ltd           Australia's #1 Internet Web Hosting Company
Level 1, 96 Lytton Road.           Network Operations - Systems Engineer
PO Box 4169, East Brisbane.                       phone: +61 7 3249 2583
Queensland, Australia.                            pgp key id: 0x900E515F



_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to