1.

Solve : how to remove varible from a list?

Answer»

hey I am doing something LIKE following:

VAR1='1 2 3 4 5'

for var in $var1 {Need to choose the variable randomly used rand($var1) but its not working }
do
echo $var
done

now as i print the $var i need this value should be removed from the variable $var1, how to do that ?

Thanks
RG Quote from: roohi on November 28, 2011, 01:46:09 AM


var1='1 2 3 4 5'

for var in $var1 {Need to choose the variable randomly used rand($var1) but its not working }
do
echo $var
done


Solve teh problem of by using following :

Code: [Select]var1=$(echo $var1 | sed "s/$var//")
But still How can i select the random varible from the list Question is there.
Please suggest.make an array of variable in list , FIND the index of that array .
Do x=rand()%index to GENERATE the random number and with that random number go to the array element : array

This will give you the random selection for each time.

Thanks
RG


Discussion

No Comment Found