hello ,
I want the output as
Let the script is as below
first=second
second=third
My requirement is I want the output as fourth through $first
i am doing
echo ""`echo "echo $"$""$first""""`""
its giving echo $second but i want ouput as third
hello ,
I want the output as
Let the script is as below
first=second
second=third
My requirement is I want the output as fourth through $first
i am doing
echo ""`echo "echo $"$""$first""""`""
its giving echo $second but i want ouput as third
root@isau02:/data/info> first=second
root@isau02:/data/info> second=third
root@isau02:/data/info> eval echo $`echo $first`
third
Thanks you for the reply,
Ca we do it with just echo command without using eval
Not that I know. Why do you mind the eval?
Depending on the shell you use try this:
echo ${!first}
no there is no issues but I want to know is it possible to do using echo command
thanks ripat its working
now the case is
first=second
second=third
third=fourth
now i want fourth as output through first
Don't think it's possible through variable substitution.
Looking for something like this,
it will work for any such levels
#! /opt/third-party/bin/perl
my %dataHash = ();
$dataHash{first} = second;
$dataHash{second} = third;
$dataHash{third} = fourth;
my $key = first;
while ( defined $dataHash{$key} ) {
$key = $dataHash{$key};
}
print "val: $key\n";
exit (0);
Even am not sure how to do that. As the levels increase, even if there is a solution, in my opinion that won't look good and not readable.