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 Answers 2

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)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .