Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

There are two directories I can change to:

Program Files/       Program Files (x86)/

I can change to first one by writing:

cd Program\ Files

But the second for second one:

cd Program\ Files\ (x86)

I get:

bash: syntax error near unexpected token `('

What is the right way to change to second directory?

share|improve this question
up vote 8 down vote accepted

You have to escape the parentheses:

cd Program\ Files\ \(x86\)

Pressing TAB will usually complete the command line for you, and will give hints how to quote the file/directory names.

share|improve this answer
Yes, Tab completes, but I have two directories with the same name till (x86) so it only completes to "Program Files". – enedene Jun 11 '12 at 8:46
@enedene That's right, although afterwards you can type \ and take advantage of completion. – lgarzo Jun 11 '12 at 8:51
An alternative that may be useful in this case is to use shell globbing. For example, cd P TAB ??x86? TAB will likely (depending on what else you have in the relevant directory) complete out to Program Files (x86). – Michael Kjörling Jun 11 '12 at 9:08
At some point backslashes become more of a problem than they're worth. If you have more than one or two special characters it's simpler to quote the entire file name; either "Program Files (x86)" or 'Program Files (x86)' will work. – MadScientist Jun 11 '12 at 12:34
Hitting TAB multiple times should cycle through the available matches. cd Prog TAB TAB. – Lars Rohrbach Jun 11 '12 at 14:53

Another way to accomplish the same is to quote the path containing whitespace:

cd "Program Files (x86)"

This also works with tab-completion so you can type:

cd "Program<Space><Tab><Space><Tab>

Notice the opening double-quote. Then you will get:

cd "Program Files (x86)"/
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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