3

How can i cd into a symbolically linked directory but, when moving from there, doing it relatively to the real directory?

For example

dir_1
    link_to_dir_3 ->

..

dir_2
    dir_3

If I do cd link_to_dir_3 and then cd .. I wanto tp go to dir_2 and not dir_1. Thanks

2
cd `pwd -P`
cd ..

The first cd will take you from dir_1/link_to_dir_3 to dir_2/dir_3.

1

Use readlink:

cd $(readlink -n link)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.