Created
September 22, 2014 03:16
-
-
Save Prince781/df6633dbe671461bf0ae to your computer and use it in GitHub Desktop.
Generates data from a prime list.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # gendata.sh | |
| function print_ij() { | |
| # print j'th field (column) of the i'th line | |
| awk -v i=$1 -v j=$2 'FNR == i {print $j}' $3 | |
| } | |
| function gendata() { | |
| n=$(($1 - 1)) | |
| fname=$2 | |
| for i in $(seq 0 $n); do | |
| modulus=`print_ij $((1 + $i / 9)) $((1 + $i % 9)) $fname` | |
| val=$(($RANDOM % $modulus)) | |
| if [ $val -eq 0 ]; then val=1; fi | |
| echo $val $modulus | |
| done | parallel echo {} > output.txt | |
| } | |
| gendata $1 $2 | |
| # ex: ./gendata 200 primes.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment