Register a domain and help support LQ
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 05-09-2010, 08:01 PM   #1
LQ Newbie
Registered: May 2010
Posts: 1

Rep: Reputation: 0
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
Old 05-09-2010, 09:18 PM   #2
Registered: Jul 2004
Location: Chennai, India
Distribution: UBUNTU 5.10 since Jul-18,2006 on Intel 820 DC
Posts: 755

Rep: Reputation: 177Reputation: 177
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.
Old 05-10-2010, 04:23 AM   #3
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian except for netbook still on Slackware 13.37 (and I have to support Ubuntu)
Posts: 8,572
Blog Entries: 30

Rep: Reputation: 1182Reputation: 1182Reputation: 1182Reputation: 1182Reputation: 1182Reputation: 1182Reputation: 1182Reputation: 1182Reputation: 1182
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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash Script: parse active process stderr, strip, dump into variables, use variables TimeFade Programming 1 02-13-2010 07:09 AM
ssh - using variables in call to start remote script from local script babag Linux - Networking 2 06-03-2008 05:50 PM
set variables in a bash script; ansi PS1 color script donnied Programming 4 11-21-2007 12:33 PM
Get strings from list using variables mwade Programming 5 10-28-2006 09:01 PM
(bash) how to list all variables? Duudson Programming 11 03-24-2005 01:35 PM

All times are GMT -5. The time now is 01:27 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration