I have a dir /var/real-dir
I've created a soft link to it like this
ln -s /var/realdir /var/virtual-dir
Having that my working directory is /var/virtual-dir
, I'm searching for a way to cd to real-dir
with as less typing as possible.
I have a dir /var/real-dir
I've created a soft link to it like this
ln -s /var/realdir /var/virtual-dir
Having that my working directory is /var/virtual-dir
, I'm searching for a way to cd to real-dir
with as less typing as possible.
You can use cd -P .
Note that this only updates the PWD
and OLDPWD
environment variables; the kernel-level current directory remains unchanged.
Alternatively, you can use the -P
option with the initial cd
like cd -P /var/virtual-dir
.
You can:
cd "$(readlink -f .)"
If this is too much typing, you can create a helper function in your .bashrc
, like this:
function cdlink() {
cd "$(readlink -f .)"
}
source ~/.bashrc
or start a new shell and can simply type:
cdlink