Link to home
Start Free TrialLog in
Avatar of nicky s
nicky sFlag for United States of America

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"
ASKER CERTIFIED SOLUTION
Avatar of farzanj
farzanj
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry, you said temp then

for temp in $str
do
    echo $temp
done
Avatar of nicky s

ASKER

hum-tum_tit_for_tat_SIZE = 40


INST = hum-tum

 eval TEMP_SIZE="$"${INST}_tit_for_tat_SIZE

it is not evaluating to 40 rather it is evaluating to -tum_tit_for_tat_SIZE
can you pls fix it



Avatar of nicky s

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.
Avatar of nicky s

ASKER

getting same value ...
Avatar of nicky s

ASKER

taht did not fix the issue
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nicky s

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
Avatar of nicky s

ASKER

can you pls show me the possible solutions for the above example

 substitute or get rid of dash
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial