Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cygpath not able to convert Windows path to Linux path

Tags:

cygwin

cygpath

Im trying to convert the file paths to/from Linux and Windows on Windows Machine.

unix path to windows works fine.

$ cygpath -w /cygdrive/c/CYGWIN/CYGBuild/build.mak
C:\CYGWIN\CYGBuild\build.mak

But windows path to Linux gives wrong output. i.e Missing '/' and also cygdrive

$ cygpath -u c:\cygwin\cygbuild\build.mak
c:cygwincygbuildbuild.mak

Anyone faced this issue?? Share your experience.

Thanks

like image 749
Jeyaram Avatar asked Sep 27 '12 11:09

Jeyaram


2 Answers

I got answer for this question.

cygpath -u 'c:\cygwin\cygbuild\build.mak'

i.e path should be given in single quotation.

like image 129
Jeyaram Avatar answered Oct 16 '22 21:10

Jeyaram


Actually as far as I know; you need forward slashes in paths used in cygwin. Single quotations help in cases where there are spaces (and my guess in this case; using backslashes instead of forward slashes) in the path. Otherwise backslashes are like escape characters, while spaces (although not in your case) require escape characters themselves. So quoting the path tends to eliminate such hassles.

Here are links that help me understand this:

  • This opencv (using cygwin) tutorial, page 4, where there's an example of paths used, with and without quotes, indicating when one might need them.
  • Also this is very useful; a list of Cygwin's FAQs, including how to deal with spaces (or in this case, backslashes in the path where adding quotes would help).
like image 32
Noha Kareem Avatar answered Oct 16 '22 20:10

Noha Kareem