> On Dec 5, 2014, at 9:08 PM, ToddAndMargo <toddandma...@zoho.com> wrote:
> 
> Hi All,
> 
> This took me an very frustrating hour to figure out.  Especially
> since I was looking for something like awk's "-F" command.
> 
> I hope this save someone else from pulling their hair out!
> (I was trying to do a substitution with a ton of forward slashes
> in it from a variable.   AAAAHHHHH!!!!!)
> 
> -T
> 
> 
> 
> Example of substitute example:
> 
> 
> $ echo "$(echo "TRUE" | sed -e 's/TRUE/FALSE/g')"
> FALSE
> 
> "g" is for "global"
> 
> 
> 
> Example with variables (use full quotes):
> 
> $ X="abcd"
> $ Y="xyz"
> $ echo $X | sed -e "s/${X}/${Y}/"
> xyz
> 
> 
> If a variable uses a "/" inside it, use a different "delimiter" (the
> first character after the "s" tells sed what the delimiter is):
> 
> 
> $ X="./abcd"
> $ Y="./xyz"
> $ echo $X | sed -e "s|${X}|${Y}|"
> ./xyz

This works inside of vi too.

I recall years ago when using “vi’ clones.  Before VIM became popular and I 
would use other clones.  They generally only supported / as a delimiter, and 
using something different (I normally use -) was an example of where their 
compatibility broke down.

Reply via email to