Skip to content

Instantly share code, notes, and snippets.

@larzconwell
Created February 11, 2012 04:58
Show Gist options
  • Save larzconwell/1796546 to your computer and use it in GitHub Desktop.
Save larzconwell/1796546 to your computer and use it in GitHub Desktop.
Interactive shell script prompt
init_num=0
init() {
init_num=$(expr $init_num + 1)
if [[ "$init_num" -le "9" ]]; then
read -p "Uni:00$init_num> " input
elif [[ "$init_num" -ge "10" ]] && [[ "$init_num" -le "99" ]]; then
read -p "Uni:0$init_num> " input
elif [[ "$init_num" -ge "100" ]] && [[ "$init_num" -le "999" ]]; then
read -p "Uni:$init_num> " input
else
read -p "Uni:$init_num> " input
fi
$input
init
}
init
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment