postheadericon Write a script to make following file and directory management operations


14.  Write a script to make following file and directory management operations menu based:
           Display current directory
           List directory
           Make directory
           Change directory
           Copy a file
           Rename a file
           Delete a file
           Edit a file

File Name : ex14.sh


clear
choice=y
while [ "$choice" = "y" ]
do
echo "____________________________________"
echo "          MAIN MENU       "
echo "____________________________________"
echo "1 - DISPLAY CURRENT DIRECTORY"
echo "2 - LIST DIRECTORY"
echo "3 - MAKE DIRECTORY"
echo "4 - CHANGE DIRECTORY"
echo "5 - COPY A FILE"
echo "6 - RENAME A FILE"
echo "7 - DELETE A FILE"
echo "8 - EDIT A FILE"
echo "9 - EXIT"
echo "____________________________________"

echo "ENTER THE CHOICE :- "
read choice
case $choice in

            1)         pwd;;

            2)         ls -l;;

            3)        echo "Enter Directory Name "
                       read dir_name
                       mkdir $dir_name
                       echo "[ $dir_name ] Sucessfully Created Directory"
                       ;;

            4)         echo "Enter the Absolute Path to change the directory: "
                        read apath
                        cd $apath
                        echo "Working path changed successfully!"
                        pwd
                        ;;

            5)         echo "Enter name of file: "
                        read filename
                        echo "Copy where? "
                        read apath
                        cp $filename $apath
                        echo "File $filename copied successfully to $apath"
                        ;;

            6)         echo "Enter Current File Name: "
                        read oname
                        echo "Enter New File Name: "
                        read nname
                        mv $oname $nname
                        ;;

            7)         echo "Enter file Name : "
                        read fdel
                        if [ -f $fdel ]; then
                            rm -i $fdel
                        fi
                        ;;

            8)         echo "Enter filename to open it in Text Editor: "
                        read filename
                        cat $filename
                        cat >> $filename
                        #vi $filename
                        ;;

            9)         exit
                        ;;

            *)         echo "Invalid Choice ....."
                        ;;
            esac
 echo "Do u want to continue.....? [ y / n ]"
 read choice
 case $choice in
  Y|y) choice=y;;
  N|n) choice=n;;
  *) choice=y;;
 esac
done

0 comments:

Blog Archive

Total Pageviews

© BipinRupadiya.com. Powered by Blogger.