Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find what variables have been declared?

Status
Not open for further replies.

scriptfinder

Technical User
Apr 17, 2006
18
US
I have a unix script that uses a lot of variables. I would like to search for all the variables(I can manually find for all the variables I used but it is time consuming) and unset them at the end of the script. Help me if you know any shortcut to search and print all variables that are declared in a shell script.
 
You don't have to. The script runs in it's own invocation of the shell, so when the script ends, that shell terminates and all variables declared during the script are destroyed/removed.

So, to answer your question, the command "[tt]exit[/tt]" at the end of your script will unset all variables declared during the script.

The only exception to this is if you are sourcing the script, in which case they do stick around.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top