Question

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.

Was it helpful?

Solution

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/-
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top