Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
| Download
Project: ./finalproject.sh
Path: 2023-12-06-file-1.bash
Views: 17Image: ubuntu2204
!/bin/bash1# =============================================================2# Final project menu option3# VG4# 12/5/20235# Menu is created for user to select an option from 1-66# ./finalproject.sh7# ============================================================8while true; do9echo ' Menu'10echo '1. Display current date and time'11echo '2. Display the first letter of your first name'12echo '3. Display the line from the 'Twelve Days of Christmas' song'13echo '4. Sum of the two integers in your age'14echo '5. Random'15echo '6. Exit'1617read -p 'Pick a selection from the menu (1-6): ' choice181920if [ $choice -eq 6 ];21then break222324elif [ $choice -eq 1 ]; then25datenow()26{27echo "Today's date and time are: "28date29}30datenow31323334elif [ $choice -eq 3 ]; then35363738read -p 'Pick number 1-12: ' choice239if [ $choice2 -eq 1 ]; then40echo 'A partidge in a pear tree'41elif [ $choice2 -eq 2 ]; then42echo 'two turtle doves'43elif [ $choice2 -eq 3 ]; then44echo 'Three French hens'45elif [ $choice2 -eq 4 ]; then46echo 'Four calling birds'47elif [ $choice2 -eq 5 ]; then48echo 'Five gold rings'49elif [ $choice2 -eq 6 ]; then50echo 'Six geese a-laying'51elif [ $choice2 -eq 7 ]; then52echo 'Seven swans a-swimming'53elif [ $choice2 -eq 8 ]; then54echo 'Eight maids a-milking'55elif [ $choice2 -eq 9 ]; then56echo 'Nine ladies dancing'57elif [ $choice2 -eq 10 ]; then58echo 'Ten lords a-leaping'59elif [ $choice2 -eq 11 ]; then60echo 'Eleven pipers piping'61elif [ $choice2 -eq 12 ]; then62echo 'Twelve drummers drumming'63else64echo 'Invalid number input. Please a number between 1 and 12.'6566fi67686970elif [ $choice -eq 4 ]; then71read -p 'Sum of your two digits in your age (two digits): ' age72if [[ $age =~ ^[0-9][0-9]$ ]]; then73digit1=$(echo $age | cut -c 1)74digit2=$(echo $age | cut -c 2)75sum=$((digit1 + digit2))76echo 'The sum of the two numbers in your age is: ' $sum77else78echo 'Please enter a number that is two digits.'7980fi8182elif [ $choice -eq 2 ]; then8384read -p "Enter your first name and the first letter will be returned: " name85name=$(echo "$name" | tr -d ' ')86echo "The first letter of your first name is: ${name:0:1}"8788899091elif [ $choice -eq 5 ]; then92echo "What is your favorite car?"93read -p "Please enter your favorite car: " favCar94echo "Very cool, $favCar is a great car."959697fi9899100done101102103