今天看了点材料,写了个菜单选择的程序,菜单程序在界面上给人的感觉是比较亲切的,和使用者的互动性也是比较接近的,总之比较人性化,就是到这个点上了。
由于是初学者,下面的代码比较简陋,高手可以飘过。。。
input=
until
echo "----------------------------------"
echo "please enter your choise:(1-6)"
echo "(1) List you selected directory"
echo "(2) Change to you selected directory"
echo "(3) Create a new file"
echo "(4) Edit you selected file"
echo "(5) Remove you selected file"
echo "(6) Exit Menu"
echo "----------------------------------"
read input #读入用户输入的内容,并存入变量
test $input -eq 6 #若输入为6,则退出,否则继续
do
case $input in #开始CASE IN CASE结构
1) ls;;
2) echo "Enter target directory:"
read dir
cd $dir;;
3) echo "Enter a file name:"
read file
touch $file;;
4) echo "Enter a file name:"
read file
vi $file;;
5) echo "Enter a file nmae:"
read file
rm $file;;
esac #结束CASE结构
done
until
echo "----------------------------------"
echo "please enter your choise:(1-6)"
echo "(1) List you selected directory"
echo "(2) Change to you selected directory"
echo "(3) Create a new file"
echo "(4) Edit you selected file"
echo "(5) Remove you selected file"
echo "(6) Exit Menu"
echo "----------------------------------"
read input #读入用户输入的内容,并存入变量
test $input -eq 6 #若输入为6,则退出,否则继续
do
case $input in #开始CASE IN CASE结构
1) ls;;
2) echo "Enter target directory:"
read dir
cd $dir;;
3) echo "Enter a file name:"
read file
touch $file;;
4) echo "Enter a file name:"
read file
vi $file;;
5) echo "Enter a file nmae:"
read file
rm $file;;
esac #结束CASE结构
done
附件:http://down.51cto.com/data/2354515
本文转自你是路人甲还是霍元甲博客51CTO博客,原文链接http://blog.51cto.com/world77/226903如需转载请自行联系原作者
world77