Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi all,
I want to define a global variable. If I do:
Code:
foo="bar"
the variable is only defined for the current term, not for the terms I'm going to open.
If I do:
Code:
export foo="bar"
it is not better, because my variable is not a classical environment variable like PATH or TERM, but a "personal" one.
I don't want to set the variable in a configuration file like .bashrc, because the variable changes from time to time (it is not the same during the whole session).
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789
Rep:
No shell variable will cross different terminals.
Use a file to store the content, and have the variable being updated on the other terminals by reading again that file.
No shell variable will cross different terminals.
Use a file to store the content, and have the variable being updated on the other terminals by reading again that file.
Yeah, that would be an easy way... but it is somewhat "dirty". It's a bit curious that there is no clean way to do that with linux.
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789
Rep:
I don't feel it is dirty.
Should you really need that feature, a way to implement it would be to patch the shell source code to have a shared memory pool accessible by every shell instance, and have some variables content stored there. Not a quick job.
Should you really need that feature, a way to implement it would be to patch the shell source code to have a shared memory pool accessible by every shell instance, and have some variables content stored there. Not a quick job.
Good idea! I'm gonna learn C, get to know the shell source code and register the http://regedit.sourceforge.net web page
Actually it was just to get a small script running, and the file trick works, so I will keep this easy solution ^^
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.