Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

In terminal I want to change a directory to something with a # sign in it. For example and can't seem to remember how to do this. From the command line I think it is suppose to be cd / but doesn't seem to work.

share|improve this question

Actually the best way to do this is to use the \ escape character. The method that @Shauna suggests will work in this case but has limitations. For example if the filename has quotes in it what do you do? this?:

cd "some """Movie Title"""" 

No, that would be silly. You would do this:

cd some\ \"Movie\ Title\"

The next character after the escape \ is not interpretted by the shell. This is what we want.

There are three methods of escaping character in bash.

  • Double quotes

Least powerful method. Preserves literal value except for dollar sign, backticks, and backslash.(

  • Single quotes

Most powerful. Hides all special characters.

  • Backslash

Similar to single quotes, but only hides one character at a time.

A good resource for this is TLDP

share|improve this answer
I wouldn't say @Shauna 's method is incorrect, but it's important to be aware of the limits of the method. Thanks for pointing it out. – I-Ii Mar 7 '13 at 22:08
@Jason I edited my post – shakabra Mar 7 '13 at 22:23

Just put quotes around it, like this:

cd ""

If you lead with a /, then it's going to look for the file or folder in the root directory (just fyi).

share|improve this answer
Alternatively escape the # by writing \ – teppic Mar 7 '13 at 21:55

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.