LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How do I cd into a directory with a leading backslash? (https://www.linuxquestions.org/questions/linux-general-1/how-do-i-cd-into-a-directory-with-a-leading-backslash-464678/)

closet geek 07-16-2006 07:41 PM

How do I cd into a directory with a leading backslash?
 
Say I'm here:

/home/me/

ls -l:

drwxrwxrwx 2 me me 4.0K Apr 10 22:57 \folder/

how do I cd into \folder/ ?

cg

DrOzz 07-16-2006 07:49 PM

cd "\folder"

closet geek 07-16-2006 08:00 PM

Afraid not, I get:

-bash: cd: \folder: No such file or directory

cd

Matir 07-16-2006 08:07 PM

tried cd \\folder?

closet geek 07-16-2006 08:11 PM

Yep, the same error message!

cg

Matir 07-16-2006 08:13 PM

Are you sure there are no hidden characters or anything in the directory name, just a backslash? \\folder works for me.

homey 07-16-2006 10:48 PM

You could start the name and use the tab key to complete it.
For example: cd \\fold<tab>

cs-cam 07-16-2006 10:55 PM

I use zsh as opposed to bash but 'cd \\dir' works fine here. Maybe this, it's worked for me before when typos lead to weird directory names.
Code:

cd -- \\dir

closet geek 07-17-2006 04:18 AM

Quote:

Originally Posted by homey
You could start the name and use the tab key to complete it.
For example: cd \\fold<tab>

Nope that didn't work.

cg

closet geek 07-17-2006 04:19 AM

Quote:

Originally Posted by cs-cam
I use zsh as opposed to bash but 'cd \\dir' works fine here. Maybe this, it's worked for me before when typos lead to weird directory names.
Code:

cd -- \\dir

...or that.

cg :cry:

closet geek 07-17-2006 04:20 AM

Quote:

Originally Posted by Matir
Are you sure there are no hidden characters or anything in the directory name, just a backslash? \\folder works for me.

It could well be, how do I go about checking? Is there not an elaborate work around similar to:

ls -l | grep me | awk '{print $9)' | xargs cd

?

cg

Matir 07-17-2006 09:08 AM

To check, you can do: 'ls -Q'

This will show any control characters in an octal-encoded form.

Let us know what this shows.

closet geek 07-17-2006 09:51 AM

Thanks, but it reports all is well:

Code:

"\240"/
was the output the folder is called: \240

This is driving me nuts! I can neither delete or cd into this directory...

cg

closet geek 07-17-2006 09:59 AM

Maybe this helps, when I type cd then hit tab it brings up a list of choices, one of them is:

Code:

/
There is a deliberate space there before the / as that's what the output is. I've tried cd " /" but it doesn't work.

cg

closet geek 07-17-2006 10:09 AM

Ok using vim (ahhh vim) to view the directory structure it labels the directory as:

Code:

<a0>/
surely that'll help someone figure this out.

cg


All times are GMT -5. The time now is 07:51 AM.