开发者

Changing to a directory named -

I have a script that traverses the directory tree using pushd and popd. It 开发者_高级运维is choking on a directory named -. I have tried:

pushd -- -

But the dash is still interpreted as an option (and the previous directory is pushed on the stack). I have the same problem with cd.


In different flavors, this is an interview question. (How would I remove a file named "-"?)

$ cd ./-
$ pushd ./-
$ pushd ./$next
$ pushd $PWD/- # Yay JL
$ pushd /what/ever/-
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜