[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: sed question



On Fri, Nov 03, 2000 at 08:10:48AM -0500, Jesse Goerz wrote:
> I'm trying to write a script and as part of it I need to change the "/" in a
> variable to a "." and then put it right back into another variable.  I've tried
> using sed but can't seem to grip these regular expressions 8-(.  Here's what I
> got so far:
> 
> echo $variable_before | sed s///./ variable_after
> 
> ...but that doesn't seem to work.  I've tried every possible variant (well,
> not every one, otherwise it'd be working for me) and even explored awk's man
> page.  Any suggestions (or the POA if you have it :-)

[eb@socrates eb]$ foo=usr/bin
[eb@socrates eb]$ echo $foo
usr/bin
[eb@socrates eb]$ bar=$(echo $foo | sed -e 's/\//./g')
[eb@socrates eb]$ echo $bar
usr.bin
[eb@socrates eb]$

you can also use the same variable ie:

[eb@socrates eb]$ foo=usr/bin
[eb@socrates eb]$ foo=$(echo $foo | sed -e 's/\//./g')
[eb@socrates eb]$ echo $foo
usr.bin
[eb@socrates eb]$

one problem with your sed script, you need to escape the / 

-- 
Ethan Benson
http://www.alaska.net/~erbenson/

Attachment: pgpiukzpCNfWn.pgp
Description: PGP signature


Reply to: