bash script to calculate age difference with loop
I essentially want to calculate this:
"calculate how much beer an 18+ user has drunk statistically (100 liters/year) and print this information for the user." Not sure how to calculate it i.e. use a loop or other to use the difference in specified age versus user input age, multiply the result, I made an attempt in the last section of code. Code:
#!/bin/bash |
Code:
lage=18 |
Quote:
What is your age? 19 -1800 What is your age? 78 -1800 What is your age? 23 -1800 |
Code:
beerperyear=100 Code:
beer=$( echo "$age $legalage $beerperyear" | awk '{ printf("%.0f\n", ($1-$2)*$3) }' ) |
The bash code example from uhelp has mixed up uage and age variables, a simple change will fix it:
Code:
(( beeryears = uage - lage )) |
Great that worked!
|
All times are GMT -5. The time now is 01:44 PM. |