Is is possible (and how) to have a “virtual” soft link whose value depends on the shell environment?

Posted on

Is is possible (and how) to have a “virtual” soft link whose value depends on the shell environment? – Managing your servers can streamline the performance of your team by allowing them to complete complex tasks faster. Plus, it can enable them to detect problems early on before they get out of hand and compromise your business. As a result, the risk of experiencing operational setbacks is drastically lower.

But the only way to make the most of your server management is to perform it correctly. And to help you do so, this article will share nine tips on improving your server management and fix some problem about linux, bash, , , .

The question could probably be reworded. What I would like to have is certain path, say /workingsrc to refer to a different real path per shell (bash) instance simultaneously.

So in an instance of bash I can do ls /workingsrc and get the contents of /foo/bar and in another instance that is running at the same time in the same machine do ls /workingsrc and get the contents of /foo/zoo.

Do you know if there is a way to do this? I’m using linux and bash.

Solution :

Variant symlinks is what you want, but are only on *BSD and AFS filesystem. Working with environment variables is much easier (see Hyppy response).

You can probably do this with environment variables. For example:
Shell 1:

WORKINGSRC=/foo/bar
ls $WORKINGSRC

Shell 2:

WORKINGSRC=/foo/zoo
ls $WORKINGSRC

Back on shell 1:

ls $WORKINGSRC

You should still see /foo/bar on shell 1, even after setting the variable to a different value in shell 2.

Leave a Reply

Your email address will not be published. Required fields are marked *