Re: sed question
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
Try:
variable_after=`echo $variable_before | sed 's/\//./' `
(you must escape the "/")
If you want to replace all the occurences of "/" add an 'g' :
variable_after=`echo $variable_before | sed 's/\//./g' `
You can do this also only with bash:
variable_after=${variable_before/\//.}
and for multiple occurences:
variable_after=${variable_before//\//.}
Andrei
Reply to: