Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi all,
I'm creating a script to try and generate large volumes of test data. Now, the problem is that its not the most efficient, I've used mainly ksh to do this.
My test data needs to include some unique data, which I've done by incrementing stuff, which is fine. Where I think its severly slowing down the processing is that I'm using the $RANDOM variable to generate random data
# My script
create_rand_txn_amnt()
{val=$RANDOM
pounds=`echo $val | cut -c1-3`
pence=`echo $val | cut -c4-5`
echo "${pounds}.${pence}"
}#call the script within a loop
x=0
while [ $x -lt 300000 ]
do
amount=`create_rand_txn_amt`
print -n "${amount}$othervalues $morevalues"\n
done#####################
I'm a bit rusty with the unix scripting, and so I'm hoping someone can suggest a way I can do this a lot quicker - I'm thinking arrays of values (It doens't really have to be totally random), but I'm not sure where to go with it.
Cheers,
k.

Lose all that cut and echo stuff. If you are using ksh, try:
Counter=0
typeset -L3 pounds
typeset -R2 pencewhile [[ $Counter -le 30000 ]]
do
VAL=$RANDOM
pounds=$VAL
pence=$VAL
print $pounds.$pence
(( Counter +=1 ))
doneDon't need all that cut and echo stuff. Your script is about as random as your're going to get while still keeping it simple.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |