SHARE
TWEET

Untitled

a guest Sep 20th, 2019 90 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
  7. }
  8.  
  9. function createdir {
  10.     echo 'Please enter the name of directory which you want to create: '
  11.     read nameofcd
  12.     mkdir $nameofcd
  13. }
  14.  
  15. function removedir {
  16.     echo 'Please enter the name of directory which you want to delete: '
  17.     read nameofrd
  18.     echo "Are you sure that you want to remove $nameofrd (y/yes - if yes)"
  19.     read cond
  20.     if  [ $cond = "y" ]  | [ $cond = "yes" ]; then
  21.         rm -r $nameofrd
  22.     else
  23.         echo "Directory wasn't removed"
  24.     fi
  25. }
  26.  
  27. while true
  28. do
  29.     echo '
  30. Select menu option:
  31. 1. current directory
  32. 2. change directory
  33. 3. print content of current directory
  34. 4. create directory
  35. 5. remove directory
  36. 6. exit
  37.     '
  38.     read menu
  39.     case $menu in
  40.         1)
  41.         pwd
  42.         ;;
  43.         2)
  44.         chandir
  45.         ;;
  46.         3)
  47.         ls -la
  48.         ;;
  49.         4)
  50.         createdir
  51.         ;;
  52.         5)
  53.         removedir
  54.         ;;
  55.         6)
  56.         exit 1
  57.         ;;
  58.         *)
  59.         echo 'Invalid input'
  60.         ;;
  61.     esac
  62. 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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top