Created
May 7, 2021 19:59
-
-
Save miaoles/27a3b7eb13f49525ba59ad7b3ca6a3ba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CONTINUE=true | |
main_menu () { | |
echo "Enter the letter for one of the following options:" | |
echo "1. Display today's date and time." | |
echo "2. Display first 5 lines of top command's output." | |
echo "3. Display a list of who is logged in." | |
echo "4. Display disk usage for /home/admin in human readable format." | |
echo "5. Display file system usage in human readable format." | |
echo "0. Exit." | |
echo "" | |
read MENU_OPTION | |
echo "" | |
} | |
execute_option () { | |
if [ $MENU_OPTION = 1 ]; then | |
date | |
elif [ $MENU_OPTION = 2 ]; then | |
top -n1 -w80 >> top.txt | |
head -5 top.txt | |
rm top.txt | |
elif [ $MENU_OPTION = 3 ]; then | |
who | |
elif [ $MENU_OPTION = 4 ]; then | |
sudo du -h /home/admin | |
elif [ $MENU_OPTION = 5 ]; then | |
sudo df -h | |
elif [ $MENU_OPTION = 0 ]; then | |
CONTINUE=false | |
else | |
$MENU_OPTION is invalid. | |
fi | |
} | |
while [ $CONTINUE = true ]; do | |
echo "" | |
main_menu | |
execute_option | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment