#!/bin/bash # Password generator for PIE #set -x #Content and length of serial code MATRIX="ABCDEFGHIJKLMNOPQRSTUVWXYZ23456789" LENGTH="10" #Select the pie code name echo " PIE code 1) PCSFREE8 2) PCS2 3) PCS4 4) PCS8 5) PCS12 Please select one" read SELECT case "$SELECT" in 1) PIECODE="PCSFREE8" ;; 2) PIECODE="PCS2";; 3) PIECODE="PCS4";; 4) PIECODE="PCS8";; 5) PIECODE="PCS12";; *) echo "Wrong choice";exit;; esac #Select the amount of codes echo "Number of codes 1) 1.000 2) 5.000 3) 10.000 4) 25.000 5) 50.000 6) 100.000 Please select one" read SELECT case "$SELECT" in 1) AMOUNT="1000";; 2) AMOUNT="5000";; 3) AMOUNT="10000";; 4) AMOUNT="25000";; 5) AMOUNT="50000";; 6) AMOUNT="100000";; esac #Remove old files test -f ${PIECODE}.csv && rm ${PIECODE}.csv #Start creating the codes while [ "${x:=1}" -le "$AMOUNT" ] do n=0 PASS="" while [ "${n:=1}" -le "$LENGTH" ] do PASS="$PASS${MATRIX:$(($RANDOM%${#MATRIX})):1}" # echo "$PASS" let n+=1 done #printf "$PIECODE;${PASS:0:5}-${PASS:5:5}\n" >> ${PIECODE}.csv printf "${PASS:0:5}-${PASS:5:5}\n" >> ${PIECODE}.csv printf "." let x+=1 done echo "" echo "$AMOUNT codes created and placed in ${PIECODE}.csv"