#!/bin/bash
function test () {
while true
do
echo "adding information"
echo "your name ?"
read name
echo "your sex ?"
read sex
echo "your age ?"
read age
echo "$name:$sex:$age"
read -p "is this correct?"
case "$REPLY" in
[yY]*)
echo "adding informati..........."
echo "$name:$sex:$age">>datafile
sort -u datafile -o datafile
echo -n "do you want to go back to the main menu?"
read ans
if [[ $ans == [nN] ]]
then
return
else
continue
fi
;;
*)
echo "do you want to try again?"
read answer
case "$answer" in
[yY]*)
continue
;;
*)
exit
;;
esac
;;
esac
done
}
datafile=$HOME/datafile
if [ -e $datafile ]
then
echo "$(basename $datafile) does not exitst" >&2
exit 1
fi
PS3="select one :"
select answer in 'add info' 'delete info' 'update info' exit
do
case $answer in
"add info")
test
break
;;
"delete info")
ls
break
;;
"update info")
echo "updating~~~~~~~"
break
;;
exit)
echo "bye bye"
exit 0
;;
*)
echo "bad choice"
continue
;;
esac
done
阅读(702) | 评论(0) | 转发(0) |