Sponsored By

Sign in to follow this  

Show All Set Variables

Recommended Posts

I think you want to do arrays.. (bash does one dimention arryas)

here is a quick bash array

bash-2.05b$ cat test
echo ${DATE[1]}

you could also do this

echo" input an answer"
read inp
echo "input another answer"
read inp2
echo ${DATE[1]}
echo ${DATE[2]}

Share this post

Link to post
Share on other sites
Is ther a way to show(list) all set and/or exported varibles in a bash shell?

$ set

will print all shell variables, including those not exported.

$ printenv


$ env

will print exported variables. The latter will also allow you to modify the environment before issuing a command.

I have a substitution question. Lets say I do this

[email protected] shane $ DATE=${one:-two}
[email protected] shane $ echo $DATE

How would I get it to echo the value one?

$ echo one


In the form ${one:-two}, 'one' is the name of a variable, so the value won't be 'one' unless you happen to have

$ one=one


Edited by jcl

Share this post

Link to post
Share on other sites

wow that set command is handy. Now I am able to kind of see what is happening.

I thought that $DATE would change depnding on what 'one' was set to. It does but 'one' has to be set before doing


I was setting 'one' after using the above command. Then It has no effect one the variable DATE.

So long as 'one' is not set before using DATE=${one:-three} three is substituted.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this