LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to list the variables that are used in a script? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-list-the-variables-that-are-used-in-a-script-806857/)

alexandrum77 05-09-2010 07:01 PM

How to list the variables that are used in a script?
 
Is there a command that can list the variables that I am using in a script? I mean the variables that I created in the script not the environment or local variables. For example if I have a script that has the following var's like : name=Alex, age=20, postal_code=12345, how can I list them all @ once WITHOUT using echo $name, $age and so on. Imagine I have a lot of variables and i can't echo them all. Thanks

AnanthaP 05-09-2010 08:18 PM

Dont know whether it will work, but a way may be to `env` at the beginning of the script to establish a baseline and then `env` later and `diff` them.

catkin 05-10-2010 03:23 AM

The set command lists all variables currently in scope. It could be used at the beginning of a script to list all the inherited variables (environment plus positional parameters) and then later; the difference between the lists would be the created variables.


All times are GMT -5. The time now is 05:42 AM.