Home » Questions » Computers [ Ask a new question ]

The CD command with "-" argument will change to previous directory. Is there a way to know which directory it is?

The CD command with "-" argument will change to previous directory. Is there a way to know which directory it is?

The command

Asked by: Guest | Views: 321
Total answers/comments: 1
Guest [Entry]

"You can also use ~- (anywhere you can use tilde expansion) instead of $OLDPWD:

# Copy a file from the previous working directory.
cp ~-/file1 .

There is also ~+ for $PWD, which is useful for commands which require an absolute directory:

./configure --prefix ~+/root

Note that things like --prefix=~+/root won't work due to the rules of tilde expansion; use --prefix=""$PWD/root"" instead."