Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to `cd` into directory with the name `-`? [closed]

Tags:

bash

cd

Here is an example. I'm creating a directory named - and I can't cd into it. The command cd - returnes me to the previous directory. And I'm a bit supprised that cd "-" works the same way. I can enter that directory using the full path ~/-, but is there other way?

user@server:~$ cd /tmp
user@server:/tmp$ cd
user@server:~$ mkdir -
user@server:~$ cd -
/tmp
user@server:/tmp$ cd
user@server:~$ cd "-"
/tmp
user@server:/tmp$ cd ~/-
user@server:~/-$
like image 377
bessarabov Avatar asked Jul 15 '17 08:07

bessarabov


People also ask

How do I convert a cd to a directory with spaces?

The Drag-and-Drop ShortcutType cd followed by a space. Drag and drop the folder on to the Terminal window. Hit Return.

What permission do you need to cd into a directory?

For directories, execute permission allows you to enter the directory (i.e., cd into it), and to access any of its files.


1 Answers

use instead

cd ./-

if you are in the directory above.

like image 126
dev_null Avatar answered Oct 03 '22 05:10

dev_null