Sunday 15 January 2012

#write a program to display the menu list as follow :- # main menu # 1) create a file # 2) display a file # 3) delete a file # Do you want to exit (y/n) # If any other key is pressed then it shows "Invalid Key is Pressed"


tput clear
while :
do
echo "ENTER 1 TO CREATE A FILE"
echo "ENTER 2 TO DISPLAY A FILE"
echo "ENTER 3 TO DELETE A FILE"
echo -n "DO YOU WANT TO EXIT (Y/N)  "
read ch
case "$ch" in
1) echo -n "Enter a file name to create "
    read fname
    cat > /home/amitranjan/Documents/$fname ;;
2) echo -n "Enter a file name to Display "
    read fname1
    cat /home/amitranjan/Documents/$fname1 ;;
3) echo -n "Enter a file name to Delete "
    read fname2
    rm /home/amitranjan/Documents/$fname2
    echo "Deleted Successfully";;
y) exit ;;
Y) exit ;;
N) ;;
n) ;;
*) echo "Invalid key is Pressed"
esac
done

No comments:

Post a Comment