Search code examples
unixshellstringdosksh

Convert Unix path to DOS path


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 KornShell (ksh) scripting:

dospath=\\\\foo\\\\bar\\\\

Solution

  • Try:

    dospath=`echo $unixpath | sed 's/\//\\\\/g'`
    

    Thanks to David Wolever for reminding me to use a $ to access the value of the variable!