Logo 
Search:

Unix / Linux / Ubuntu Articles

Submit Article
Home » Articles » Unix / Linux / Ubuntu » Homework HelpRSS Feeds

Script to make File and Directory Management Operations menu based : Display Current directory, List Directory, Make Directory, Change Directory etc

Posted By: Lu Fischer     Category: Unix / Linux / Ubuntu     Views: 6913

Write a script to make Following File and Directory
Management Operations menu based

a] Display Current dirctory
b] List Directory
c] Make Directory
d] Change Directory
e] Copy A File
f] Rename A File
G] Delete A File
H] Edit a file

Code for Script to make File and Directory Management Operations menu based : Display Current directory, List Directory, Make Directory, Change Directory etc in Unix / Linux / Ubuntu

echo  "\t\t\tMenu\n
    1]  Display Current dirctory\n
    2]  List Directory\n
    3]  Make Directory\n
    4]  Change Directory\n
    5]  Copy A File\n
    6]  Rename A File\n
    7] Delete A File\n
    8] Edit a file\n
    Enter Your Choice:- \c"
    read choice
    
case"$choice"in
    1) pwd ;;
    2) ls ;;
    3) echo "Enter the Name Of Directory :-\c"
       read dir 
       if [-z $dir]; then
           echo "you have not enter the dir"elseif [ ! -e $dir]; then
        mkdir $dir
       else 
        echo "Dir Already Exists"if;;
    4) echo "Enter the Name Of Directory :-\c"
       read dir 
       if [-z $dir]; then
           echo "you have not enter the dir"elseif [ ! -e $dir ];then
          echo "Dir Not Found"else
        cd $dir
       if;;     
    5) echo "Enter Soures File:-\c"
       read sfile
       if [-z $sfile];then
           Echo "Enter the Destination file"
           read dfile
           if [-z $dfile];then
                cp -i $sfile $dfiile
           else
                echo "You have not Enter Destination"ifelse
        echo "You have not entered Sorce File"if ;;
    6)echo "Enter Soures File:-\c"
       read sfile
       if [-z $sfile];then
           Echo "Enter the Destination file"
           read dfile
           if [-z $dfile];then
                mv -i $sfile $dfiile
           else
                echo "You have not Enter Destination"ifelse
        echo "You have not entered Sorce File"if ;;    
    7)echo "Enter the File"
      read delfile
      if [-z $delfile] ; then
          echo "you have not Entered File"elseif [ ! -e $delfile]
             echo "File Does not Exist"else
         echo "Confirm Delete [y/n] :- \c"
           read  delans
            if [$delans -e y -o delans -e Y];then
               rm $delfile
           ifif;;
    8)exit
esac
    
  
Share: 



Lu Fischer
Lu Fischer author of Script to make File and Directory Management Operations menu based : Display Current directory, List Directory, Make Directory, Change Directory etc is from Frankfurt, Germany.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!