Hello,
I would like to parse all the shell variables and get the name and the value for each variable. Set command get the list of variables but I don't know if there is a command such getopts to get each of them.
regards,
Teo
Hello,
I would like to parse all the shell variables and get the name and the value for each variable. Set command get the list of variables but I don't know if there is a command such getopts to get each of them.
regards,
Teo
is this what you are looking for?
for line in `set`; do echo $line; done
Oh, thanks, I've already use it but I have a problem. In addition to the shell variables it prints the rest of script begining with the method which calls the command set.
As sample
for i in `set | grep urlWebservice`
do
field1_awk=`echo "$i" | awk -F= '{print $1}'| grep urlWebservice`
if [ $field1_awk != "" ] ; then
field2_awk=`echo "$i" | awk -F= '{print $2}'`
echo $field1_awk ":" $field2_awk
fi
done
it works but the last line displayed is for i in `set | grep urlWebservice`
how does your set output look like, and what do you expect it to be in the end?
My script contains this line at the begining
. ${DirName}/localConfiguration.conf
where localConfiguration.conf is a conf file
The content of the conf file is:
urlWebserviceCheckAddress=McoConfigGlobal.commonGLOBALUrlWebservice
urlWebserviceFindBillingAccount=McoConfigGlobal.commonGLOBALUrlWebservice
urlWebserviceGetBillingAccount=McoConfigGlobal.commonGLOBALUrlWebservice
urlWebserviceGetBillingAccountMovement=McoConfigGlobal.commonGLOBALUrlWebservice
The script must display these variables.
don't see why you need to use set then
awk -F"=" '/urlWebservice/{print $1":"$2}' ${DirName}/localConfiguration.conf
ok, thanks