Saving sed output to shell var.

Joel Hammer Joel
Mon May 17 11:47:59 PDT 2004


This works:
CURRENT_TEST1=`echo ${CURRENT_TEST} | sed 's/\ /\\\ /'`

Don't ask me why. I would guest that the \ is signaling to the shell
to use the special meaning of the next character, which isn't special,
so it is just dropped. Why the command line behaves differently from
the script is one of those mysteries of life.

Joel



On Sat, May 31, 2003 at 10:29:09PM -0000, skeeterhawkca wrote:
> I can do the following on the command line:
> 
> CURRENT_TEST="The Test"
> 
> echo ${CURRENT_TEST} | sed 's/\ /\\ /'
> 
> which produces 
> 
> The\ Test
> 
> Which is what I am looking to do in a shell script. (bash)
> 
> So if added the following to my shell:
> 
> CURRENT_TEST1=`echo ${CURRENT_TEST} | sed 's/\ /\\ /'`
> 
> But I only get this (with the echo ${CURRENT_TEST1} script command)
> 
> The Test
> 
> Any help would be great.
> 
> Phil
> 
> 
> ------------------------ Yahoo! Groups Sponsor ---------------------~-->
> Get A Free Psychic Reading! Your Online Answer To Life's Important Questions.
> http://us.click.yahoo.com/Lj3uPC/Me7FAA/ySSFAA/dkFolB/TM
> ---------------------------------------------------------------------~->
> 
>  
> 
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 
> 
> 


More information about the Linux-users mailing list