#!/bin/bash # Usage: # write a file that declares # an array called "list" # and call this script # with the path to the file # as the first argument if ! [[ -f "$1" ]] then echo "Please specify a file." exit 1 fi source "$1" if [[ -z "${list[@]}" ]] then echo "List is empty." exit 1 fi i=0 while [[ $(($i+1)) -le ${#list[@]} ]] do read -p "$(($i+1)). " buf if [[ "${list[$i]}" != "$buf" ]] then echo 'wrong!' exit 1 fi (( i++ )) unset buf done echo "yay!"