#!/bin/bash USAGE="gen_seed.sh ROOT FOLDERS FILES FILENAMES INTEGERS USER DIR : generate a file USER.seed in the DIR folder, which can be then used to generate exercises." if [[ $# != 7 ]] ; then echo -e $USAGE ; exit 0 ; fi # This users home root=$1 # How many random folders, files, filenames and integers you need folders=$2 files=$3 filenames=$4 ints=$5 # username USER=$6 # Seeds storage DIR=$7 if echo $DIR | grep -v /$ ; then DIR=$DIR/ ; fi mkdir $DIR$USER ; find $root -type d | shuf | head -n $folders > $DIR$USER/folders.seed find $root -type f | shuf | head -n $files > $DIR$USER/files.seed cat haddock.list | shuf | head -n $filenames > $DIR$USER/filenames.seed if [[ -s $DIR$USER/ints.seed ]] ; then rm $DIR$USER/ints.seed ; fi for i in $(seq 1 $ints) ; do echo $((3 + $RANDOM % 13)) >> $DIR$USER/ints.seed done