2

I am trying to navigate to this below path in cygwin,

C/Program Files (x86)/temp/lfc/utilities

but unfortunately, it shows the below error

$ cd C/Program Files (x86)/temp/lfc/utilities
bash: syntax error near unexpected token `('

Could you please let me know, what is wrong here..

4 Answers 4

3

The command:

cd C/Program Files (x86)/temp/lfc/utilities

is trying to call cd with three arguments rather than the correct one:

  • C/Program
  • Files
  • (x86)/temp/lfc/utilities and the third of those arguments contains characters that cause bash some grief - they're actually defined as metacharacters and, as per the bash doco:

Each of the metacharacters listed above under DEFINITIONS has special meaning to the shell and must be quoted if it is to represent itself.

Just surround the whole lot in quotes, like:

cd '/cygdrive/C/Program Files (x86)/temp/lfc/utilities'

You'll notice I've also prefixed it with the CygWin cygdrive mount point. I'm fairly certain that's still needed, at least from the version I installed a couple of months back.

Sign up to request clarification or add additional context in comments.

Comments

2

Cygwin uses POSIX path nomenclature. To easily convert a Windows path into a Cygwin path you can use the cygpath tool:

$ cygpath 'C:\Program Files\foo'
/cygdrive/c/Program Files/foo

Also this tool can convert POSIX path to Windows:

$ cygpath -w '/cygdrive/c/Program Files/foo'
C:\Program Files\foo

A third solution is to drag and drop a file or folder from the Windows explorer directly into your mintty terminal. You will get you Windows path directly converted into the Cygwin's format.

Comments

1

You could also use PROGRA~1, PROGRA~2 and PROGRA~3 like this :

  • cd /cygdrive/c/PROGRA~1 is equivalent to cd /cygdrive/c/Programmes
  • cd /cygdrive/c/PROGRA~2 is equivalent to cd /cygdrive/c/Program\ Files\ \(x86\)
  • cd /cygdrive/c/PROGRA~3 is equivalent to cd /cygdrive/c/ProgramData

1 Comment

Are those short forms guaranteed to map like that? I have a vague recollection that wasn't the case always.
0

You can directly use windows paths with:

cd $(cygpath -u "C:\Program Files (x86)\temp\lfc\utilities")

This is useful for environment variables like:

cd  $(cygpath -u "$USERPROFILE")/Downloads
cd "$(cygpath -u "$PROGRAMFILES")/Program Name"

You can know more about cygpath on https://cygwin.com/cygwin-ug-net/cygpath.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.