Is there a way to cd
out of a directory which has just been deleted (go up one level into the upper folder which still exists?
It often happens to me that I have a console opened for a folder, and then I delete the folder with my temporary test data and create another one.
However, both cd ..
and cd $(pwd)/..
only get me to the trash bin, and not to the upper directory when I try to leave the deleted folder.
So, current situation is:
$ mkdir -p /home/me/test/p1
$ cd /home/me/test/p1
now I delete the folder p1
$ cd ..
me:~/.local/share/Trash/files$ ...
I'm now searching for a way to get into /home/me/test/
and not into the Trash bin. Is there such a command?
$PWD
and not$(pwd)
. Bash keeps track of names of directories in PWD. Instead the commandpwd
gives the current working directory (so it moves with directory moving or symlinks).