0

I don't know why someone would make a directory with a leading hyphen, e.g. named "-1". When I try to change to that directory, it says invalid option.

I tried putting "-1" in quotes but that didn't help either. Can anyone tell me how to access these types of dirs?

$ ls -l
total 3
lrwxrwxrwx 1 root root 2 Dec  7 18:51 lastFailedBuild -> -1
lrwxrwxrwx 1 root root 2 Dec  7 18:51 lastUnstableBuild -> -1
lrwxrwxrwx 1 root root 2 Dec  7 18:51 lastUnsuccessfulBuild -> -1
$ cd -1
-bash: cd: -1: invalid option
cd: usage: cd [-L|[-P [-e]] [-@]] [dir]
$

1 Answers1

2

You can anchor the name -1 in the current directory by prefixing it with ./. Then, then resulting name ./-1 does not start with a dash and cd will not try to interpret it as an option.

user2233709
  • 1,669