SHARE
TWEET

Untitled

a guest Sep 20th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. function chandir {
  4.     echo 'Please enter the name of directory you want to change to: '
  5.     read nameofd
  6.     cd $nameofd 2>> error_log
  7.     if [ "$?" = "0" ]; then
  8.         echo 'OK'
  9.     else
  10.         echo 'No such directory'
  11.     fi
  12. }
  13.  
  14. function createdir {
  15.     echo 'Please enter the name of directory which you want to create: '
  16.     read nameofcd  
  17.     mkdir $nameofcd
  18. }
  19.  
  20. function removedir {
  21.     echo 'Please enter the name of directory which you want to delete: '
  22.     read nameofrd    
  23.     if [ -d $nameofrd ]; then
  24.         echo "Are you sure that you want to remove $nameofrd (y/yes - if yes)"
  25.         read cond
  26.         if  [ $cond = "y" ] || [ $cond = "yes" ]; then    
  27.             rm -r $nameofrd
  28.         else
  29.             echo "Directory wasn't removed"
  30.         fi
  31.     else
  32.         rm -r $nameofrd 2>> error_log
  33.         echo 'No such directory'
  34.     fi
  35. }
  36.  
  37. while true
  38. do
  39.     echo '
  40. Select menu option:
  41. 1. current directory
  42. 2. change directory
  43. 3. print content of current directory
  44. 4. create directory
  45. 5. remove directory
  46. 6. exit
  47.     '
  48.     read menu
  49.     case $menu in
  50.         1)
  51.         pwd
  52.         ;;
  53.         2)
  54.         chandir
  55.         ;;
  56.         3)
  57.         ls -la
  58.         ;;
  59.         4)
  60.         createdir
  61.         ;;
  62.         5)
  63.         removedir
  64.         ;;
  65.         6)
  66.         exit 0
  67.         ;;
  68.         *)
  69.         echo 'Invalid input'
  70.         ;;
  71.     esac
  72. done
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top