Results 1 to 3 of 3
Dear friends,
I have a code which needs to be executed 50 times with a different seed (between 0 and 1) every time.
How do I write a shell cript ...
- 01-30-2009 #1Just Joined!
- Join Date
- Jan 2009
- Location
- Helsinki, Finland
- Posts
- 8
Linux Scritpting: Using a variable
Dear friends,
I have a code which needs to be executed 50 times with a different seed (between 0 and 1) every time.
How do I write a shell cript to change the seed value ever time.
This is what I have been able to do. Please take me through.
for (( i = 1 ; i <= 50; i++ ))
do
./my_code .111
done
How do I change the value of 0.111 in every iteration. I am using argc argv to read the seed as input.
Looking for an early reply.
Thanks,
Anks
- 01-30-2009 #2Just Joined!
- Join Date
- Jan 2009
- Location
- Helsinki, Finland
- Posts
- 8
To add to the above post.
It would not be possible for me to use expr`` as I am running the script on a cluster and expr doesnt work on it.
TIA
- 01-31-2009 #3Linux User
- Join Date
- Jun 2007
- Posts
- 318
You could use bash's builtin variable RANDOM which generates a number between 0 and 32767. A little math and you can convert that to a number between 0 and 1.
Code:SEED=`echo "$RANDOM / 32767" | bc -l` ./my_code $SEED


Reply With Quote