Code: Select all
#!/bin/bash
usage() {
echo 'cloze: cloze deletion test generator'
echo 'usage: cloze count filename'
echo 'example: cloze 5 /etc/motd'
exit 1
}
[[ -z $1 ]] && usage
[[ -z $2 ]] && usage
[[ ! -e $2 ]] && echo "file $2 does not exist" && usage
i=0
for word in `cat $2`; do
((++i))
if [[ $i -eq $1 ]]; then
i=0
echo "$word " >> ~/.wordlist
printf "____ "
else
printf "$word "
fi
done
echo
echo "Word list:"
shuf ~/.wordlist | tr "\\n" " "
echo
rm ~/.wordlist
Code: Select all
user@grill:~$ cloze 7 kreuzer
Travellers left and entered our car ____ every stopping of the train. Three ____ however, remained, bound, like myself, for ____ farthest station: a lady neither young ____ pretty, smoking cigarettes, with a thin ____ a cap on her head, and ____ a semi-masculine outer garment; then her ____ a very loquacious gentleman of about ____ years, with baggage entirely new and ____ in an orderly manner; then a ____ who held himself entirely aloof, short ____ stature, very nervous, of uncertain age, ____ bright eyes, not pronounced in color, ____ extremely attractive,—eyes that darted with rapidity ____ one object to another. This gentleman, ____ almost all the journey thus far, ____ entered into conversation with no fellow-traveller, ____ if he carefully avoided all acquaintance. ____ spoken to, he answered curtly and ____ and began to look out of ____ car window obstinately.
Word list:
as face, with forty at had wearing When companion, persons, nor gentleman arranged the in during from the decisively, but