Question
Unix/Linux I am struggling to make this code work. It keeps giving errors when trying to run. let current_yr='date +%-Y' let current_mth='date +%-m' let current_day='date
Unix/Linux
I am struggling to make this code work. It keeps giving errors when trying to run.
let current_yr='date +%-Y' let current_mth='date +%-m' let current_day='date +%-d'
echo -e "Do you want to run agecalc (Yes or No): \c" read ans while [$ans = "Yes" ] do echo -e "Enter your name: \c" read name echo -e "Enter your birth year (EX: 1997): \c" read yr_of_birth echo -e "Enter your month of birth(Ex 01-12): \c" read mth_of_birth
if [ $mth_of_birth -le $current_mth ] then let age=$current_yr-$yr_of_birth let age_in_mths=$current_mth-$mth_of_birth else let age=$current_yr-$yr_of_birth-1 let age_in_mths=$current_mth-$mth_of_birth+12 fi
echo $name ", Your age is" $age "years and" $age_in_mths "months."
echo -e "Do you want to run the agecalc again? (Y/N) \c" read ans done
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started