How to format a dos path to a unix path on cygwin command line

Posted by Jennette on Stack Overflow See other posts from Stack Overflow or by Jennette
Published on 2010-04-14T22:05:12Z Indexed on 2010/04/14 22:13 UTC
Read the original article Hit count: 363

Filed under:
|
|
|
|

When using Cygwin, I frequently copy a Windows path and manually edit all of the slashes to Unix format. For example, if I am using Cygwin and need to change directory I enter:

cd C:\windows\path

then edit this to

cd C:/windows/path

(Typically, the path is much longer than that). Is there a way to use sed, or something else to do this automatically? For example, I tried:

echo C:\windows\path|sed 's|\|g'

but got the following error
sed: -e expression #1, char 7: unterminated `s' command

My goal is to reduce the typing, so maybe I could write a program which I could call. Ideally I would type:

conversionScript cd C:/windows/path

and this would be equivalent to typing:

cd C:\windows\path

© Stack Overflow or respective owner

Related posts about cygwin

Related posts about sed