4

I am usually trying to use the cygwin terminal to move to a nested directory. The problem is the windows directory are not immediately interpreted.

So I had to do two step:

$ cygpath -u "C:\Develop\blah\blah\blah\too_deep\"
/cygdrive/c/Develop/blah/blah/blah/too_deep/
$ cd /cygdrive/c/Develop/blah/blah/blah/too_deep/

I need to convert the path first then paste the result to change it.

I tried to use redirect but it does not work. Any ideas?

$ cygpath -u "C:\Develop\blah\blah\blah\too_deep\" | cd

=> No results.

1
10

Try this:

cd $(cygpath -u 'C:\Develop\blah\blah\blah\too_deep\')

The $(command) construct does a command substitution and is replaced with the output of the command.

10

You'll need to enclose it in double quotes if the path contains spaces:

cd "$(cygpath -u 'c:\Program Files\')"
4
  • You repeat the old answer! Apr 21 '16 at 7:08
  • 4
    actually, not quite. He's enclosed that with double quotes. Not sure if it'll work, but it does seem marginally unique
    – Journeyman Geek
    Apr 21 '16 at 7:48
  • Confirmed as working. However so does the version without double quotes as per the accepted answer.
    – DavidPostill
    Apr 21 '16 at 9:55
  • 5
    When I test previous version: $ cd $(cygpath -u 'c:\Program Files\') I met the error message: -bash: cd: /cygdrive/c/Program: No such file or directory. Apr 21 '16 at 11:16
0

or simple old fashioned

cd `cygpath --unix "C:\Develop\blah\blah\blah\too_deep\ "`

Please note the space after the last backslash.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.