I have a while loop with an string array and a simple randomize for them.
My problem however is to count how many times the same strings have appear when the loop was running.
Ex :
oc/open string has appeared 3 times
rw/read string has appeared 2 times
oc/close string has appeared 3 times
etc....
At the moment im using if else methods inside the loop, but there must be a better way to count them? Any tips?
function injection {
COUNTER=0
countopen=0
while [ $COUNTER -lt 10 ]; do
module[0]="oc/open"
module[1]="oc/close"
module[2]="rw/read"
module[3]="rw/write"
randModule=$[$RANDOM % ${#module[@]}]
export MODULE=${module[$randModule]}
echo $MODULE
if [ $randModule == 0 ]; then
let countopen++
#let countclose++
#etc
#etc
fi
let COUNTER++
done
echo "Open $countopen"
}
injection
Aucun commentaire:
Enregistrer un commentaire