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 :-)
[EMAIL PROTECTED] eb]$ foo=usr/bin [EMAIL PROTECTED] eb]$ echo $foo usr/bin [EMAIL PROTECTED] eb]$ bar=$(echo $foo | sed -e 's/\//./g') [EMAIL PROTECTED] eb]$ echo $bar usr.bin [EMAIL PROTECTED] eb]$ you can also use the same variable ie: [EMAIL PROTECTED] eb]$ foo=usr/bin [EMAIL PROTECTED] eb]$ foo=$(echo $foo | sed -e 's/\//./g') [EMAIL PROTECTED] eb]$ echo $foo usr.bin [EMAIL PROTECTED] eb]$ one problem with your sed script, you need to escape the / -- Ethan Benson http://www.alaska.net/~erbenson/
pgpEJSoPRWuYA.pgp
Description: PGP signature