5

I have a folder named abcd\fff\ggg\ddd

How do I cd into it?

6
  • How on earth did you manage to get a folder with slashes in the name?! Most operating systems go well out of their way to prevent that from ever, ever happening. Also, what operating system are you using? It would make answering your question easier ;)
    – nhinkle
    Commented Aug 18, 2010 at 22:32
  • im using ubuntu
    – Or W
    Commented Aug 18, 2010 at 23:26
  • @nhinkle: I've noticed the opposite: Most operating systems allow everything that is not forbidden for a good reason. Any well-written Unix program — including Nautilus, GNOME's graphical file browser — will let you enter anything as file name (except a slash /). Commented Aug 19, 2010 at 20:57
  • @nhinkle: (Well, okay, Nautilus won't let you enter newline characters. But it's as simple as mkdir "foo[Enter]bar" in the shell.) Commented Aug 19, 2010 at 20:58
  • Ahhh, ok. On Windows, we use \ for directories, not / like on unix, so \ is therefore a prohibited character. That makes more sense now (and hence my question about the OS ;) )
    – nhinkle
    Commented Aug 20, 2010 at 9:57

2 Answers 2

7

You have to escape the backslash character in order for it to work:

cd abcd\\fff\\ggg\\ddd/

Escaping means prefixing the backslash (also have to do this if the directory contains a space) with, funnily enough, a backslash. Linux interprets a single backslash as the escape character, allowing you to access directories and files containing spaces, backslashes, and other special characters.

That is best practice; it is a good idea to get in the habit of understanding how and when to use the escape character if you're going to be using Linux command line. The other answer provided:

cd 'abcd\fff\ggg\ddd'

will also work. I provided mine as a more complete and 'correct' answer, since understanding the concept of escape characters is essential to proper CLI interaction.

4
cd 'abcd\fff\ggg\ddd'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .