3
rated 0 times
[
3]
[
0]
/ answers: 1 / hits: 4091
/ 3 Years ago, fri, july 9, 2021, 6:11:29
I'm writing my first bash script and I've hit a snag. Here's an example where I ask for a name, ask for an age, and display a message that changes depending on whether or not the age is <= 35:
#!/bin/bash
ageLimit = 34
echo "What is your name?"
read userName
echo "How old are you?"
read userAge
if (( "$userAge" -le "$ageLimit" )); then
echo "Hey, $userName. At $userAge years old, you are young."
else
echo "Gosh, $userName. At $userAge years old, you're pretty old."
fi
No matter what number I answer for age, I am told I am young. This is running on Raspbian -- in case that helps. Thanks!
Jeremy
More From » bash