Please use ***
[code][/code]*** tags around your code and data, to preserve the original formatting and to improve readability. Do
not use quote tags, bolding, colors, "start/end" lines, or other creative techniques.
Processing of user input when using
read and such is generally better done with a
case statement.
And for simple multiple choice menus like this I'd suggest using a
select loop.
Code:
#!/bin/bash
clear
PS3='What do you want to do?: '
select what in Shutdown Restart Abort; do
echo "You selected: $what"
case $REPLY in
1) shutdown -h now ;;
2) shutdown -r now ;;
3) echo "Terminating script without action."
break ;;
*) echo "invalid selection" ;;
esac
done
exit 0
BTW, remember that
shutdown requires that the user running the script have proper permission to do so.