Skip to content

Instantly share code, notes, and snippets.

@miaoles
Created May 7, 2021 18:51
Show Gist options
  • Save miaoles/1b43ac8c50f8793615deb2aefb07d25b to your computer and use it in GitHub Desktop.
Save miaoles/1b43ac8c50f8793615deb2aefb07d25b to your computer and use it in GitHub Desktop.
CCM 3
#!/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 | head -n 5
elif [ $MENU_OPTION = 3 ]; then
who
elif [ $MENU_OPTION = 4 ]; then
du -h /home/admin
elif [ $MENU_OPTION = 5 ]; then
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