problem in assigning value to variable have value fo other variable

my script is some thing like this

i11="{1,2,3,4,5,6,7,8,9,10,11,}"

echo "enter value"
read value   ..............suppose i11


x="$value"
echo "$($value)"           .............the echo should be {1,2,3,4,5,6,7,8,9,10,11,}

but its showing "i11" only.

plz help me out to get desired o/p

try execute with same subshell..(read(with pipe) executed normally in separate shell and we can use "(........)" ) for process in the same shell..
(this means --> grouping with parentheses)

# value=$(echo $i11|(read value;echo $value))

regards
ygemici

1 Like

thanks ygemici,

but problem is something like this

the complete script is

i1="{01}"
i2="{01,02}"
i3="{01,02,03}"
i4="{01,02,03,04}"
i5="{01,02,03,04,05}"
i6="{01,02,03,04,05,06}"
i7="{01,02,03,04,05,06,07}"
i8="{01,02,03,04,05,06,07,08}"
i9="{01,02,03,04,05,06,07,08,09}"
i10="{01,02,03,04,05,06,07,08,09,10}"
i11="{01,02,03,04,05,06,07,08,09,10,11}"
i12="{01,02,03,04,05,06,07,08,09,10,11,12}"
i13="{01,02,03,04,05,06,07,08,09,10,11,12,13}"
i14="{01,02,03,04,05,06,07,08,09,10,11,12,13,14}"
i15="{01,02,03,04,05,06,07,08,09,10,11,12,13,14,15}"
i16="{01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16}"
i17="{01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17}"
i18="{01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18}"
i19="{01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,20}"
i20="{01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20}"
i21="{01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21}"
i22="{01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22}"
i23="{01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23}"
i24="{01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24}"
i25="{01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25}"
i26="{01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26}"
i27="{01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27}"
i28="{01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28}"
i29="{01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29}"
i30="{01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30}"
i31="{01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}"

echo -n "ENTER DATE "
read value



x="$value"
echo "$($x)"

this $x should be one value from the above like "{1,2,.......}" as per input

I think you should use indirect referencing.

Not sure if this works..Try this..

 
i11="{1,2,3,4,5,6,7,8,9,10,11,}"
value=i11
eval echo \$$value

this i11 is not fixed its variable from i1 to i31

how to do that....................

what you are trying to achieve ?

is anything related to date calculation?

yes,

if i will enter any date then it should be interpreted as from 01 to that entered date..

suppose its 21 then the interpretation should be 01,....,21

the actual need is

i m passing command though expect for listing specific file/specific pattern from 01 to date entered.
for that command is "ls *{01,02,.....$date}*"
but i m not getting how to send this 01 to $date
if u ll use counter then it will give 1,2,3,....$date
but i want 01,02,..11,12...$date
from 11 onward its ok bt before that 1 to 9 i don't know how to get 01 to 09

---------- Post updated at 02:42 AM ---------- Previous update was at 02:27 AM ----------

:confused:...............

Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.

# cat justdoit
echo -n "ENTER DATE "
read value
s=1;last=$value
## if your value contains "i" in the front of your value then --> last=$(echo $value|sed 's/^.//')
value=$(while [ $(( last -= 1 )) -gt -1 ] ; do
awk -vs=$s 'BEGIN{printf "%02d,",s}';((s++));done|awk '{sub(/^/,"\"{");sub(/,$/,"}\"")}1')
echo $value
# ./justdoit
ENTER DATE 11
"{01,02,03,04,05,06,07,08,09,10,11}"

regards
ygemici

dear ygemici

the o/p is like this

-n ENTER DATE
22
new_char[6]: s++: Expression is not complete; more tokens expected.
"{01}"

[quote=sagar_1986;302629811]
dear ygemici

the o/p is like this

-n ENTER DATE
22
new_char[6]: s++: Expression is not complete; more tokens expected.
"{01}"

[mod]Link: [url="Forum Video Tutorial: How to Use Code Tags"]How to use [noparse]

 tags
what is your o.s platform and shell?

try like this..
echo -n "ENTER DATE "
read value
s=1;last=$value
## if your value contains "i" in the front of your value then --> last=$(echo $value|sed 's/^.//')
value=$(while [ $(( last -= 1 )) -gt -1 ] ; do
awk -vs=$s 'BEGIN{printf "%02d,",s}';let s=s+1;done|awk '{sub(/^/,"\"{");sub(/,$/,"}\"")}1')
echo "$value"
1 Like