一个什么都学的老程序员  
C#和PHP学习历程
#!/bin/bash
clear
record_file=passwd
again=""
while [ "$again" = "" ]
do
clear
echo "            用户信息主菜单"
echo "=================================="
echo "1、  打印当前所有记录"
echo "2、  打印当前所有记录(格式化后的)"
echo "3、  打印用户名和用户ID"
echo "4、  打印(格式化了的)用户名和用户ID"
echo "5、  查询特定记录"
echo "6、  增加新记录"
echo "7、  删除记录"
echo "Q----退出"
echo -n "你的选择是:"
read num
case $num in
1)
printf "\n"
awk -F ":" '{print $1 " " $2" " $3 " " $4 " " $5 " " $6 " " $7}' passwd
printf "\n"
echo -n "按回车键继续....."
read again;;
2)
printf "\n"
sort +1 passwd | awk -F ":" '{print $1 "\t" $2 "\t" $3 "\t" $4 "\t" $5 "\t" $6 "\t" $7 "\t"}'
printf "\n"
echo -n "按回车键继续....."
read again;;
3)
printf "\n"
awk -F ":" '{print $1 "," $3}' passwd
printf "\n"
echo -n "按回车键继续....."
read again
;;
4)
printf "\n"
sort +1 passwd | awk -F ":" '{print "用户名:" $1 "\t" "用户ID:" $3}'
printf "\n"
echo -n "按回车键继续....."
read again;;
5)
printf "\n"
echo -n "输入关键字:"
read keyword
                                                                                                                                              
;;
Q)
echo "=============================="
echo "    Thanks for use!  ^_^"
echo "=============================="
again=quit;;
q)
echo "=============================="
echo "    Thanks for use!  ^_^"
echo "=============================="
again=quit;;
"")echo -n "Selection not entered. Press Enter to continue…"
read again;;
*)
echo -n "无效的代码,请按回车健继续....."
read again
;;
esac
done


posted on 2006-11-27 22:39  剑落飘香  阅读(423)  评论(0编辑  收藏  举报