Custom Search

Saturday 21 April 2012

Write a Linux shell script to list, make, delete & copy file, Linux shell script to display, change & remove a directory, Unix program list, make, delete, copy file & directory


Write a Linux shell script to list, make, delete & copy file, Linux shell script to display, change & remove a directory, Unix program list, make, delete, copy file & directory 


Write a Linux shell script to display the following menu.
1) Files- 1. List files
          2. Make a file
          3. delete a file
          4. Copy a file1.


2) Directory- 1. Make a directory
              2. Display current directory
              3. Change current directory
              4. Remove current directory
3) Quit


Program
clear
echo"1.FILE"
echo"2.DIRECTORY"
echo"3.QUIT"
echo""


echo-n"Enter your choice:"
read ch


case $ch in
1) echo""
  echo"   1. List files
  echo"   2. Make a file
  echo"   3. delete a file
  echo"   4. Copy a file
  echo""


echo-n "Enter ypur name"
read ch1


case $ch1in
 1) echo""
   is;;
 2) echo""
   echo-n "Enter file name:"
   read fn
   cat>$fn 
   echo "File successfully created"
   echo""
   is;;
 3) echo""
   echo-n"Enter file name to delete"
   read fn
   rm-r$fn
   echo""
   echo"File successfully deleted"
   echo""
   IS;;
 4) echo""
   echo-n "Enter file name from you want to copy:"
   read f1
   echo-n" Enter file name to you want to copy:"
   read f2
   cp $f1 $f2
   echo""
   echo" File successfully copied";;
   
   esac;;


2) echo""
  echo" 1. Make a directory
  echo" 2. Display current directory
  echo" 3. Change current directory
  echo" 4. Remove current directory
  echo""


  echo-n "Enter your choice:"
  read ch2
  
  case $ch2 in
  1) echo""
     echo-n "Enter the name for directory:"
     read dn
     mkdir $ dn
     echo""
     echo" Directory successfully created"
     echo""
     is;;

  2) echo-n "Current directory:"
     pwd
     echo""
     
  3) echo""
     echo-n" Current directory:"
     pwd
     echo-n"Enter the name of directory you want to go to:"
     read dn
     cd $dn
     echo"Directory has been changed successfully"
     echo-n " Current directory"
     pwd
     echo"";;
  4) echo""
     echo-n "Enter old name:"
     read od
     echo-n "Enter new name:"
     read nd
     mv $od $nd
     echo" Directory successfully renamed"
     echo"";;


     esac;;


3) exit;;
esac


Output:


1. FILE
2. DIRECTORY
3. QUIT 
Enter your choice:1


1. LIST FILES
2. MAKE FILE
3. DELETE FILE
4. COPY FILE
Enter your choice:2


All files in current directory are listed here.
<<< Previous  ||  Current  ||  Next >>>  

No comments:

Post a Comment

Laptops