【发布时间】:2014-04-16 21:41:05
【问题描述】:
您好,我正在编写一个 shell 脚本菜单,我想为用户提供选项来更改他们列出目录的方式,但是当用户键入目录时没有任何反应,它只是循环回到菜单。
如果有经验的程序员可以指出我做错了什么,请提前谢谢。 这是我目前所拥有的:
while true
do
clear
echo "Listing options "
echo "========================================="
echo "1. List Hidden Files "
echo "2. List the name of the current directory "
echo "3. show files that have a following / or * "
echo "4. show group ownership of files in the directory "
echo "5. Print the inode id for each file in the directory "
echo "6. Long listing of details about the files and the directory "
echo "7. List all sub directories encountered while listing "
echo "8. Sort by Time instead of name "
read dirChoice
case "$dirChoice" in
1)echo -n "Please Enter the directory you wish to list: "
read dList
ls -a ~/$dList;
break;;
2)echo -n "Please Enter the directory you wish to list: "
read dList
ls -d ~/$dList;
;;
3)echo -n "Please Enter the directory you wish to list: "
read dList
ls -f ~/$dList;
;;
esac
done
;;
【问题讨论】: