Subscribe to Get Free Material Updates!
Visit my new blog WebData Scraping - Web Scraping Service provider company in India.

Write a script to make following file and directory management operations menu based



  1. Display current directory
  2. List directory
  3. Make directory
  4. Change directory
  5. Copy a file
  6. Rename a file
  7. Delete a file
  8. Edit a file
clear
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 " ENTER CHOICE : ";
read ch
if [ $ch -eq 1 ];then
 echo "YOUR CHOICE IS TO DISPLAY CURRENT DIRECTORY"
 pwd=`pwd`
 echo "YOUR CURRENT DIRECTORY IS : $pwd"
elif [ $ch -eq 2 ];then
 echo "YOUR CHOICE IS TO LIST THE FILE IN DIRECTORY"
 echo "FILE AND DIRECTORIES IN CURRENT DIRECTORY IS "
 echo `ls`
elif [ $ch -eq 3 ];then
 echo "YOUR CHOICE IS TO CREATE DIRECTORY"
 echo "Enter Name Of Directory:";
 read dir
 `mkdir $dir`
 echo "Directory Created successfully";
elif [ $ch -eq 4 ];then
 echo "YOUR CHOICE IS TO CHANGE DIRECTORY"
 echo "ENTER DIRECTORY TO CHANGE"
 read dir1
 cd $dir1
 echo "CHANGED SUCCESS "`pwd`
elif [ $ch -eq 5 ];then
 echo "Enter file to COPY"
 read file
 echo "Enter Directory to which file is to be copied"
 read dir
 cp $file $dir
elif [ $ch -eq 6 ];then
 echo "YOUR CHOICE IS TO RENAME A FILE"
 echo "ENTER FILE TO RENAME"
 read file
 echo "ENTER NEW NAME"
 read name
 mv $file $name
elif [ $ch -eq 7 ];then
 echo "YOUR CHOICE IS TO DELETE A FILE"
 echo "ENTER FILE TO DELETE"
 read file
 rm -i $file
elif [ $ch -eq 8 ];then
 echo "YOUR CHOICE IS TO EDIT A FILE"
 echo "ENTER FILENAME TO EDIT "
 read file
 echo "ENTER NEW DATA TO WRITE"
 read newdata
 echo $newdata > $file
else
 echo "ENTER CORRECT OPTION"
fi


Output: 

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

 
Design by Wordpress Theme | Bloggerized by Free Blogger Templates | coupon codes