Search code examples
shellcygwin

Issue while navigating to a directory "C/Program Files (x86)" with cygwin?


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..


Solution

  • 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.