hello,
how the user can get a list of a variable/s created by himself ( different from those in env-list )
and how could he delete it/them?
thank you in advance
locale variables
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Topics in this forum are automatically closed 6 months after creation.
locale variables
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: locale variables
To see your locale variables, just type
If you want to see which ones you set, look in ~/.bashrc and ~/.profile
Code: Select all
locale
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
Your data and OS are backed up....right?
Re: locale variables
well, my question was not exactly how to see the values of the bash global built-in variables using 'locale' or 'env', but to remember myself how much and what exactly variables I have created.
I remember that some time ago while watching a video about bash I have created my own ... how to say it ... personal variables and set them to a certain values but now I can not remember the names of this variables, their values, and where they are stored.
I remember that some time ago while watching a video about bash I have created my own ... how to say it ... personal variables and set them to a certain values but now I can not remember the names of this variables, their values, and where they are stored.
- Pilosopong Tasyo
- Level 6
- Posts: 1432
- Joined: Mon Jun 22, 2009 3:26 am
- Location: Philippines
Re: locale variables
( set -o posix ; set ) | less
Unfortunately, it will list *both* shell variables (the ones you define) as well as environment variables. You will have to weed out for yourself which is which.
How to list user-defined variables declared in a script? - read here
AFAIK and to simplify, shell variables only exist within the lifetime of a script or terminal session. Once the script exits, that variable gets deallocated. You can try this in an open terminal window. Define some variables, close the terminal window, re-open, and re-enter the above command. All your user-defined variables in the previous session no longer exist.
o Give a man a fish and he will eat for a day. Teach him how to fish and he will eat for a lifetime!
o If an issue has been fixed, please edit your first post and add the word [SOLVED].
o If an issue has been fixed, please edit your first post and add the word [SOLVED].
Re: locale variables
Pilosopong Tasyo wrote:( set -o posix ; set ) | less
... shell variables only exist within the lifetime of a script or terminal session. Once the script exits, that variable gets deallocated. You can try this in an open terminal window. Define some variables, close the terminal window, re-open, and re-enter the above command. All your user-defined variables in the previous session no longer exist.
thanks for the answer!
so. the situation with the user-defined variables ( udvar ) created in the interactive bash shell became clear. once the terminal is closed all udvars disappear.
but what about a udvar created in a bash script? if a user create a variable/s in a bash shell script/s is there a command that could list all udvars, and in which scripts exactly they are? or you just have to open a given script and see what udvars it contains?
- Pilosopong Tasyo
- Level 6
- Posts: 1432
- Joined: Mon Jun 22, 2009 3:26 am
- Location: Philippines
Re: locale variables
The link I posted in my earlier reply appears to be the way to do it (unless if another member knows of an easier way, feel free to chime in). Problem is, you'll need to run the script (ckonn wrote:but what about a udvar created in a bash script? if a user create a variable/s in a bash shell script/s is there a command that could list all udvars, and in which scripts exactly they are? or you just have to open a given script and see what udvars it contains?
source scriptname
) just to make a before-and-after comparison. Doing this may prove less optimal if you scripts need to run only when certain conditions are met.o Give a man a fish and he will eat for a day. Teach him how to fish and he will eat for a lifetime!
o If an issue has been fixed, please edit your first post and add the word [SOLVED].
o If an issue has been fixed, please edit your first post and add the word [SOLVED].
Re: locale variables
Difference between env and declare -p variables:
Code: Select all
diff -y <(env|cut -d "=" -f1 | sort) <(declare -p | awk '{ print substr($3,1,match($3,"=|$")-1) }')