想创建一个简单的菜单:
#!/bin/bash
#menu
USERNAME=`whoami`
HOSTNAME=`hostname -s`
DATE=`date +%d/%m/%Y`
while :
do
tput clear
#here documents starts here
cat <<cs
----------------------------------------------------------
User

USERNAME Host

HOSTNAME Date

DATE
----------------------------------------------------------
1 : List files in current directory
2 : Use the vi editor
3 : See who is on the system
H : Help screen
Q : Exit Menu
-----------------------------------------------------------
cs
#here document finished
echo -e -n "\tYour choice[1,2,3,H,Q]:"
read CHOICE
case $CHOICE in
1) ls ;;
2) vi ;;
3) who ;;
h|H) cat <<cs
This is the help screen,nothing here yet to help you!
cs ;;
q|Q) exit 0 ;;
*) echo -e "\t\007unkown user response" ;;
esac
echo -e -n "\tHit the return key to continue"
done
但运行时会报错:
/root/bin/menu: line 36: syntax error: unexpected end of file
帮忙看一下,问题出在哪里,谢了!