petersmol
petersmol

Reputation: 61

change directory in unix shell (special characters)

I have directory name starting with --. How to enter it with cd? Basic escape charaters is not working

# cd --smol--/
    -bash: cd: --: invalid option
    cd: usage: cd [-L|[-P [-e]]] [dir]

# cd \-\-smol\-\-
    -bash: cd: --: invalid option
    cd: usage: cd [-L|[-P [-e]]] [dir]

# cd  '--smol--'
    -bash: cd: --: invalid option
    cd: usage: cd [-L|[-P [-e]]] [dir]

# cd '\-\-smol\-\-'
    -bash: cd: \-\-smol\-\-: No such file or directory

# help
  GNU bash, version 4.2.37(1)-release (i486-pc-linux-gnu)

Upvotes: 4

Views: 2301

Answers (2)

Erik Bennett
Erik Bennett

Reputation: 1099

You can prepend "./":

cd ./--smol--

Upvotes: 4

anubhava
anubhava

Reputation: 786021

You can use cd like this:

cd -- '--smol--'

OR:

cd -- --smol--

Anything after -- are not considered options for cd command.

Upvotes: 6

Related Questions