Skip to content

Instantly share code, notes, and snippets.

@StanleySathler
Last active September 12, 2019 00:59
Show Gist options
  • Save StanleySathler/1fe36ee6ce904c0f31e3a2a2f32290f9 to your computer and use it in GitHub Desktop.
Save StanleySathler/1fe36ee6ce904c0f31e3a2a2f32290f9 to your computer and use it in GitHub Desktop.
#!/bin/bash
menu_option=1
user=""
pass=""
# Keep asking for login until it is correct
while [ "$user" != "admin" ] && [ "$pass" != "admin" ]
do
echo "User: "
read user
echo "Password: "
read pass
done
# Keep showing menu until "Exit" is pressed
while [ "$menu_option" -ne 8 ]
do
echo "[+] ------------------------- [+]"
echo "[1] Create file"
echo "[2] Edit file"
echo "[3] Move file"
echo "[4] Partitions"
echo "[5] Diff"
echo "[6] Information"
echo "[7] Sorted list"
echo "[8] Sair"
echo "[+] ------------------------- [+]"
echo "Type your option: "
read menu_option
clear
case $menu_option in
"1") # Create a file
echo "Type the file name: "
read file_name
echo "Type the permission: "
read permission
mkdir $file_name
chmod $permission $file_name
;;
"2") # Change a file
echo "Type the file name: "
read file_name
if ! [ -f $file_name ]
then
touch $file_name
fi
nano $file_name
;;
"3") # Move a file
echo "Type the file name: "
read file_name
echo "Target directory: "
read target_dir
if [ -f $file_name ]
then
mv $file_name $target_dir
else
echo "The file doesn't exist"
fi
;;
"4") # Show partitions
sudo sfdisk -l -uM
;;
"5") # Show diff between files
echo "Type the first file name: "
read file_name_a
echo "Type the second file name: "
read file_name_b
if [ -f $file_name_a ] && [ -f $file_name_b ]
then
diff $file_name_a $file_name_b
fi
;;
"6") # Information
echo "Uptime: $(uptime)"
echo "User: $(whoami)"
;;
"7") # Sorted directories
ls | sort
;;
"8") # Exit
echo "Exiting..."
;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment