shell - bash ls menu option loop back to first menu -
hello writing shell script menu , want give users options change way can list directories nothing happens when user types in directory loops menu.
can of experienced programmers point out doing wrong if in advance. here have far:
while true clear echo "listing options " echo "=========================================" echo "1. list hidden files " echo "2. list name of current directory " echo "3. show files have following / or * " echo "4. show group ownership of files in directory " echo "5. print inode id each file in directory " echo "6. long listing of details files , directory " echo "7. list sub directories encountered while listing " echo "8. sort time instead of name " read dirchoice case "$dirchoice" in 1)echo -n "please enter directory wish list: " read dlist ls -a ~/$dlist; break;; 2)echo -n "please enter directory wish list: " read dlist ls -d ~/$dlist; ;; 3)echo -n "please enter directory wish list: " read dlist ls -f ~/$dlist; ;; esac done ;;
i think need read statement @ end of loop - otherwise screen cleared , output user has selected therefore lost.
esac read -p "press key continue " done this suggestion: store response in variable , use exit loop.
read -p "press x quit - other key contine " answer if [ "$answer = "x" ];then break fi
Comments
Post a Comment