Advertisement
Guest User

Untitled

a guest
Sep 25th, 2019
615
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. menu_option=1
  4. user=""
  5. pass=""
  6.  
  7. # Keep asking for login until it is correct
  8. while [ "$user" != "admin" ] && [ "$pass" != "admin" ]
  9. do
  10. echo "User: "
  11. read user
  12. echo "Password: "
  13. read pass
  14. done
  15.  
  16. # Keep showing menu until "Exit" is pressed
  17. while [ "$menu_option" -ne 8 ]
  18. do
  19. echo "[+] ------------------------- [+]"
  20. echo "[1] Create file"
  21. echo "[2] Edit file"
  22. echo "[3] Move file"
  23. echo "[4] Partitions"
  24. echo "[5] Diff"
  25. echo "[6] Information"
  26. echo "[7] Sorted list"
  27. echo "[8] Sair"
  28. echo "[+] ------------------------- [+]"
  29. echo "Type your option: "
  30.  
  31. read menu_option
  32.  
  33. clear
  34.  
  35. case $menu_option in
  36. "1") # Create a file
  37. echo "Type the file name: "
  38. read file_name
  39.  
  40. echo "Type the permission: "
  41. read permission
  42.  
  43. mkdir $file_name
  44. chmod $permission $file_name
  45. ;;
  46.  
  47. "2") # Change a file
  48. echo "Type the file name: "
  49. read file_name
  50.  
  51. if ! [ -f $file_name ]
  52. then
  53. touch $file_name
  54. fi
  55.  
  56. nano $file_name
  57. ;;
  58.  
  59. "3") # Move a file
  60. echo "Type the file name: "
  61. read file_name
  62.  
  63. echo "Target directory: "
  64. read target_dir
  65.  
  66. if [ -f $file_name ]
  67. then
  68. mv $file_name $target_dir
  69. else
  70. echo "The file doesn't exist"
  71. fi
  72.  
  73. ;;
  74.  
  75. "4") # Show partitions
  76. sudo sfdisk -l -uM
  77. ;;
  78.  
  79. "5") # Show diff between files
  80. echo "Type the first file name: "
  81. read file_name_a
  82. echo "Type the second file name: "
  83. read file_name_b
  84.  
  85. if [ -f $file_name_a ] && [ -f $file_name_b ]
  86. then
  87. diff $file_name_a $file_name_b
  88. fi
  89.  
  90. ;;
  91.  
  92. "6") # Information
  93. echo "Uptime: $(uptime)"
  94. echo "User: $(whoami)"
  95. ;;
  96.  
  97. "7") # Sorted directories
  98. ls | sort
  99. ;;
  100.  
  101. "8") # Exit
  102. echo "Exiting..."
  103. ;;
  104.  
  105. esac
  106. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement