nicky s
asked on
shell script
i have two varaibales in a string, the variables are seperated by space as below .. i need a for loop to extract each string into a variable called temp and print temp each time
str = "hum-tum bay"
str = "hum-tum bay"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
hum-tum_tit_for_tat_SIZE = 40
INST = hum-tum
eval TEMP_SIZE="$"${INST}_tit_f or_tat_SIZ E
it is not evaluating to 40 rather it is evaluating to -tum_tit_for_tat_SIZE
can you pls fix it
INST = hum-tum
eval TEMP_SIZE="$"${INST}_tit_f
it is not evaluating to 40 rather it is evaluating to -tum_tit_for_tat_SIZE
can you pls fix it
ASKER
i need the temp size value to be 40
Try this:
TEMP_SIZE=$(eval echo \$${INST}_tit_for_tat_SIZE )
Sorry don't have shell at this time to test.
TEMP_SIZE=$(eval echo \$${INST}_tit_for_tat_SIZE
Sorry don't have shell at this time to test.
ASKER
getting same value ...
ASKER
taht did not fix the issue
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i cannot use _ as i'm geeting the value from some file ..
Well, you would need to either substitute using either sed or something.
Try doing
hum\-tum=10
echo ${hum\-tum}
Probably would not work. Then the only solution would be to substitute or get rid of dash
Try doing
hum\-tum=10
echo ${hum\-tum}
Probably would not work. Then the only solution would be to substitute or get rid of dash
ASKER
can you pls show me the possible solutions for the above example
substitute or get rid of dash
substitute or get rid of dash
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
for temp in $str
do
echo $temp
done