开发者

Changing to a directory named -

开发者 https://www.devze.com 2023-02-17 05:34 出处:网络
I have a script that traverses the directory tree using pushd and popd. It 开发者_高级运维is choking on a directory named -. I have tried:

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

精彩评论

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