I have a variable that stores a Unix path, for example:
typeset unixpath=/foo/bar/
And I have to convert it to a DOS path using Korn shell scripting:
dospath=\\foo\\bar\\
I have a variable that stores a Unix path, for example:
typeset unixpath=/foo/bar/
And I have to convert it to a DOS path using Korn shell scripting:
dospath=\\foo\\bar\\
Try:
dospath=`echo $unixpath | sed 's/\//\\\\/g'`
Thanks to David Wolever for reminding me to use a $ to access the value of the variable!
If you have ksh93:
ksh-M 93t 2008-11-04$ unixpath=/foo/bar/
ksh-M 93t 2008-11-04$ print ${unixpath//\//\\\\\\\\}
\\foo\\bar\\
I would have added as a comment to eleven81's answer, but I don't have the points
to make it slightly more readable, how about using an alternative sed delimiter
i.e.
dospath=`echo $unixpath | sed 's./.\\\\.g'`