mardi 31 janvier 2017

Shuffling numbers in bash using seed

I want to create an array of integers, where the numbers are from 1...N. Each number appears once in this array. For instance array = {1, 3, 5, 2, 4} when N = 5.

In order to produce this array, I use the shuffle method as:

        array=($(shuf -i 1-$N -n $N ))

It works fine. However, I want to add seed to this code to make sure every time I run the code with the same seed, I get the same array. Is it possible to do that using the shuffle method?




Aucun commentaire:

Enregistrer un commentaire