第1个回答 2009-11-14
调试完毕:
#!/bin/sh
until
echo date..........1
echo ls............2
echo who...........3
echo pwd...........4
echo exit..........5
echo Please input your choice:
read choice
test $choice = 5
do
case $choice in
1) date;;
2) echo Enter target directory
read dir
ls $dir
;;
3) who
;;
4) pwd;;
5) exit;;
*) echo illegal Option
esac
done
第2个回答 2009-11-14
这样
#! /bin/bash
while :
do
clear
cat<<-EOF
**cmd menu**
1 ---- date (Display today and current time)
2 ---- ls (List content of current directory)
3 ---- who (See who is on the system)
4 ---- pwd (Print the current directory)
5 ---- quit the menu
EOF
printf "Choice: "
read choice
case "$choice" in
1) echo "Today is $(date +%Y-%m-%d)"
echo "Now is $(date +%T)"
;;
2) ls
;;
3) who
;;
4) echo "We are in $(pwd)"
;;
5) break
;;
*) echo "I can't understand what you want?"
;;
esac
sleep 3
done
exit 0
# end script