Hello,
On a Sun Solaris 8 system in a Bourne script I am dynamically creating and testing some variables. The problem I am having is detecting when/if a dynamic variable value does not have a value.
The assumption is that there will always be a DEST1 but the goal is to test if there are more. It is also assumed that they will be created in sequential order (DEST1, DEST2 etc.).
In this snippet, how can I test if the user created a DESTn variable, the above if does not seem to work?
Thanks,
Michael42
On a Sun Solaris 8 system in a Bourne script I am dynamically creating and testing some variables. The problem I am having is detecting when/if a dynamic variable value does not have a value.
The assumption is that there will always be a DEST1 but the goal is to test if there are more. It is also assumed that they will be created in sequential order (DEST1, DEST2 etc.).
Code:
[COLOR=green]#User Defined Variables[/color]
DEST1="/dir_x"
DEST2="/dir_y"
[COLOR=green]# Build Destination String[/color]
for i in 1 2 3 4
do
echo "$DEST$i" [COLOR=green]# <=== This displays correctly[/color]
[b]if [ -n $DEST$i ] then[/b]
[COLOR=green]# Stuff I need to do if above true[/color]
.
.
.
fi
done
In this snippet, how can I test if the user created a DESTn variable, the above if does not seem to work?
Thanks,
Michael42