今天看了點材料,寫了個菜單選擇的程序,菜單程序在界面上給人的感覺是比較親切的,和使用者的互動性也是比較接近的,總之比較人性化,就是到這個點上了.
由於是初學者,下面的代碼比較簡陋,高手可以飄過...
#!/bin/bash
#menu.sh
#QQ 384343423
#world77.blog.51cto.com
#world77@163.com
#384343423@qq.com
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