Wednesday 9 September 2015

File Handling in Shell

# pro: file handling
# Name: Kishor Sonawane
#
#
ch=1
while [ $ch -ne 0 ]
do

echo "*******************"
echo "0.exitprogram"
echo "1.Creat File"
echo "2. Rename File"
echo "3.Delete File"
echo "4.Exit to Shell"
echo "Enter choice:"
read ch
case $ch in
   1) echo "Enter file name:"
     read fname
     if [ -f $fname ]
       then
          echo "File Is Already Exist!!!"
       else
       touch $fname
       echo "File IS Creat:" $fname
      fi
      ;;
   2) echo "Enter File Name:"
 echo "Enter file name:"
     read rname
     if [ -f $rname ]
       then
echo "Enter the New File Name:"
          read new
          mv $rname $new
       echo "File Rename" $rname "to" $new
      
       else
          echo "File Is Not Present!!!"
      fi
      ;;
  3) echo "Enter file name:"
     read dname
     if [ -f $dname ]
       then
           rm $dname
        echo "File Is Deleted!!!"
        else
           echo "File Is Not Present!!!"
      fi
      ;;
   4)   exit
;;
   0)   echo "Thank you!!!"
        echo "You are exit from Program"
;;
*) echo "Wrong choice!!!"
;;
esac
done

No comments:

Post a Comment