[plug] Sed regex help
Anthony J. Breeds-Taurima
tony at cantech.net.au
Wed Jan 29 16:47:59 WST 2003
On Wed, 29 Jan 2003, Brad Campbell wrote:
> G'day all,
> I have a script where I need to convert the "\" in dos filenames to "/"
> suitable for feeding to basename.
>
> Lets say
>
> export DOC="C:\BLAH\BLAH\FRED.DOC"
> and I want to convert this to C:/BLAH/BLAH/FRED.DOC
>
> Now on the command line
> echo $DOC | sed s/\\\\/\//g
> gives me the desired output, but in a bash script
> DOC2=`echo $DOC | sed s/\\\\/\//g`
>
> gives me the unmodified original string.
>
> What am I doing wrong. I'm sure I'm going to kick myself.
I think you need a "-e"
tony at balder:~$ DOC="C:\BLAH\BLAH\FRED.DOC"
tony at balder:~$ echo $DOC
C:\BLAH\BLAH\FRED.DOC
tony at balder:~$ echo $DOC | sed -e 's/\\/\//g'
C:/BLAH/BLAH/FRED.DOC
tony at balder:~$
Yours Tony
Jan 22-25 2003 Linux.Conf.AU http://linux.conf.au/
The Australian Linux Technical Conference!
More information about the plug
mailing list