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

Re: sed question



On Fri, 03 Nov 2000, Andrei Pelinescu - Onciul wrote:
> 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 "/")


This was exactly what I needed.  Thank you!
 
> 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
-- 
Got freedom?
http://www.debian.org



Reply to: